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
26 lines (23 loc) · 1.2 KB
/
Copy pathPatchCompiler.cs
File metadata and controls
26 lines (23 loc) · 1.2 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
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));
return protoPatch.command switch
{
Command.Insert => new InsertPatch(protoPatch.urlConfig, protoPatch.nodeType, protoPatch.passSpecifier),
Command.Edit => new EditPatch(protoPatch.urlConfig, new NodeMatcher(protoPatch.nodeType, protoPatch.nodeName, protoPatch.has), protoPatch.passSpecifier),
Command.Copy => new CopyPatch(protoPatch.urlConfig, new NodeMatcher(protoPatch.nodeType, protoPatch.nodeName, protoPatch.has), protoPatch.passSpecifier),
Command.Delete => new DeletePatch(protoPatch.urlConfig, new NodeMatcher(protoPatch.nodeType, protoPatch.nodeName, protoPatch.has), protoPatch.passSpecifier),
_ => throw new ArgumentException("has an invalid command for a root node: " + protoPatch.command, nameof(protoPatch)),
};
}
}
}