-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathLogPatch.cs
More file actions
50 lines (44 loc) · 1.45 KB
/
LogPatch.cs
File metadata and controls
50 lines (44 loc) · 1.45 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Xml;
using JetBrains.Annotations;
using Godot.Serialization;
namespace Godot.Modding.Patching
{
/// <summary>
/// An <see cref="IPatch"/> that logs the state of any <see cref="XmlNode"/>s before and after applying a separate patch to them.
/// </summary>
[PublicAPI]
public class LogPatch : IPatch
{
/// <summary>
/// Initialises a new <see cref="LogPatch"/> with the specified parameters.
/// </summary>
/// <param name="patch">The patch to apply before and after logging the <see cref="XmlNode"/>.</param>
public LogPatch(IPatch patch)
{
this.Patch = patch;
}
private LogPatch()
{
}
/// <summary>
/// The patch to apply before and after logging the <see cref="XmlNode"/>.
/// </summary>
[Serialize]
public IPatch Patch
{
get;
[UsedImplicitly]
private set;
} = null!;
/// <summary>
/// Logs the XML string representation of <paramref name="data"/> before and after applying <see cref="Patch"/> to it.
/// </summary>
/// <param name="data">The <see cref="XmlNode"/> to apply the patch on.</param>
public void Apply(XmlNode data)
{
Log.Write($"Before: {data.OuterXml}");
this.Patch.Apply(data);
Log.Write($"After: {data.OuterXml}");
}
}
}