forked from sarbian/ModuleManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatchCompiler.cs
More file actions
35 lines (28 loc) · 1.34 KB
/
Copy pathPatchCompiler.cs
File metadata and controls
35 lines (28 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
namespace ModuleManager.Patches
{
public interface IPatchCompiler
{
IPatch CompilePatch(ProtoPatch protoPatch);
}
public class PatchCompiler : IPatchCompiler
{
public IPatch CompilePatch(ProtoPatch protoPatch)
{
if (protoPatch == null) throw new ArgumentNullException(nameof(protoPatch));
switch (protoPatch.command)
{
case Command.Insert:
return new InsertPatch(protoPatch.urlConfig, protoPatch.nodeType, protoPatch.passSpecifier);
case Command.Edit:
return new EditPatch(protoPatch.urlConfig, new NodeMatcher(protoPatch.nodeType, protoPatch.nodeName, protoPatch.has), protoPatch.passSpecifier);
case Command.Copy:
return new CopyPatch(protoPatch.urlConfig, new NodeMatcher(protoPatch.nodeType, protoPatch.nodeName, protoPatch.has), protoPatch.passSpecifier);
case Command.Delete:
return new DeletePatch(protoPatch.urlConfig, new NodeMatcher(protoPatch.nodeType, protoPatch.nodeName, protoPatch.has), protoPatch.passSpecifier);
default:
throw new ArgumentException("has an invalid command for a root node: " + protoPatch.command, nameof(protoPatch));
}
}
}
}