/
InsertPatch.cs
35 lines (31 loc) · 1.37 KB
/
InsertPatch.cs
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;
using System.Collections.Generic;
using ModuleManager.Extensions;
using ModuleManager.Logging;
using ModuleManager.Patches.PassSpecifiers;
using ModuleManager.Progress;
namespace ModuleManager.Patches
{
public class InsertPatch : IPatch
{
public UrlDir.UrlConfig UrlConfig { get; }
public string NodeType { get; }
public IPassSpecifier PassSpecifier { get; }
public bool CountsAsPatch => false;
public InsertPatch(UrlDir.UrlConfig urlConfig, string nodeType, IPassSpecifier passSpecifier)
{
UrlConfig = urlConfig ?? throw new ArgumentNullException(nameof(urlConfig));
NodeType = nodeType ?? throw new ArgumentNullException(nameof(nodeType));
PassSpecifier = passSpecifier ?? throw new ArgumentNullException(nameof(passSpecifier));
}
public void Apply(LinkedList<IProtoUrlConfig> configs, IPatchProgress progress, IBasicLogger logger)
{
if (configs == null) throw new ArgumentNullException(nameof(configs));
if (progress == null) throw new ArgumentNullException(nameof(progress));
if (logger == null) throw new ArgumentNullException(nameof(logger));
ConfigNode node = UrlConfig.config.DeepCopy();
node.name = NodeType;
configs.AddLast(new ProtoUrlConfig(UrlConfig.parent, node));
}
}
}