forked from sarbian/ModuleManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatchApplier.cs
More file actions
69 lines (59 loc) · 1.98 KB
/
Copy pathPatchApplier.cs
File metadata and controls
69 lines (59 loc) · 1.98 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Linq;
using ModuleManager.Logging;
using ModuleManager.Extensions;
using ModuleManager.Patches;
using ModuleManager.Progress;
namespace ModuleManager
{
public class PatchApplier
{
private readonly IBasicLogger logger;
private readonly IPatchProgress progress;
private readonly IPatchList patchList;
private readonly UrlDir.UrlFile[] allConfigFiles;
public string Activity { get; private set; }
public PatchApplier(IPatchList patchList, UrlDir databaseRoot, IPatchProgress progress, IBasicLogger logger)
{
this.patchList = patchList;
this.progress = progress;
this.logger = logger;
allConfigFiles = databaseRoot.AllConfigFiles.ToArray();
}
public void ApplyPatches()
{
foreach (IPass pass in patchList)
{
ApplyPatches(pass);
}
}
private void ApplyPatches(IPass pass)
{
logger.Info(pass.Name + " pass");
Activity = "ModuleManager " + pass.Name;
foreach (IPatch patch in pass)
{
try
{
foreach (UrlDir.UrlFile file in allConfigFiles)
{
patch.Apply(file, progress, logger);
}
progress.PatchApplied();
}
catch (Exception e)
{
progress.Exception(patch.UrlConfig, "Exception while processing node : " + patch.UrlConfig.SafeUrl(), e);
try
{
logger.Error("Processed node was\n" + patch.UrlConfig.PrettyPrint());
}
catch (Exception ex2)
{
logger.Exception("Exception while attempting to print a node", ex2);
}
}
}
}
}
}