diff --git a/Confuser.Core/ConfuserEngine.cs b/Confuser.Core/ConfuserEngine.cs index 9cca6592a..edf71f6fc 100644 --- a/Confuser.Core/ConfuserEngine.cs +++ b/Confuser.Core/ConfuserEngine.cs @@ -77,7 +77,7 @@ static void RunInternal(ConfuserParameters parameters, CancellationToken token) // 1. Setup context var context = new ConfuserContext(); context.Logger = parameters.GetLogger(); - context.Project = parameters.Project; + context.Project = parameters.Project.Clone(); context.PackerInitiated = parameters.PackerInitiated; context.token = token; diff --git a/Confuser.Core/Project/ConfuserProject.cs b/Confuser.Core/Project/ConfuserProject.cs index ed9441ff2..13a6b3faa 100644 --- a/Confuser.Core/Project/ConfuserProject.cs +++ b/Confuser.Core/Project/ConfuserProject.cs @@ -147,6 +147,21 @@ internal void Load(XmlElement elem) { public override string ToString() { return Path; } + + /// + /// Clones this instance. + /// + /// A duplicated module. + public ProjectModule Clone() { + var ret = new ProjectModule(); + ret.Path = Path; + ret.IsExternal = IsExternal; + ret.SNKeyPath = SNKeyPath; + ret.SNKeyPassword = SNKeyPassword; + foreach (var r in Rules) + ret.Rules.Add(r.Clone()); + return ret; + } } /// @@ -243,6 +258,17 @@ internal void Load(XmlElement elem) { foreach (XmlElement i in elem.ChildNodes.OfType()) Add(i.Attributes["name"].Value, i.Attributes["value"].Value); } + + /// + /// Clones this instance. + /// + /// A duplicated setting item. + public SettingItem Clone() { + var item = new SettingItem(Id, Action); + foreach (var entry in this) + item.Add(entry.Key, entry.Value); + return item; + } } @@ -261,7 +287,7 @@ public Rule(string pattern = "true", ProtectionPreset preset = ProtectionPreset. Preset = preset; Inherit = inherit; } - + /// /// Gets or sets the pattern that determine the target components of the rule. /// @@ -564,5 +590,25 @@ public void Load(XmlDocument doc) { } } } + + /// + /// Clones this instance. + /// + /// A duplicated project. + public ConfuserProject Clone() { + var ret = new ConfuserProject(); + ret.Seed = Seed; + ret.Debug = Debug; + ret.OutputDirectory = OutputDirectory; + ret.BaseDirectory = BaseDirectory; + ret.Packer = Packer == null ? null : Packer.Clone(); + ret.ProbePaths = new List(ProbePaths); + ret.PluginPaths = new List(PluginPaths); + foreach (var module in this) + ret.Add(module.Clone()); + foreach (var r in Rules) + ret.Rules.Add(r); + return ret; + } } } \ No newline at end of file