Skip to content
This repository has been archived by the owner on Jan 27, 2019. It is now read-only.

Commit

Permalink
Add more project API
Browse files Browse the repository at this point in the history
  • Loading branch information
yck1509 committed Oct 13, 2015
1 parent 78cb337 commit da99f43
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Confuser.Core/ConfuserEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
48 changes: 47 additions & 1 deletion Confuser.Core/Project/ConfuserProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,21 @@ internal void Load(XmlElement elem) {
public override string ToString() {
return Path;
}

/// <summary>
/// Clones this instance.
/// </summary>
/// <returns>A duplicated module.</returns>
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;
}
}

/// <summary>
Expand Down Expand Up @@ -243,6 +258,17 @@ internal void Load(XmlElement elem) {
foreach (XmlElement i in elem.ChildNodes.OfType<XmlElement>())
Add(i.Attributes["name"].Value, i.Attributes["value"].Value);
}

/// <summary>
/// Clones this instance.
/// </summary>
/// <returns>A duplicated setting item.</returns>
public SettingItem<T> Clone() {
var item = new SettingItem<T>(Id, Action);
foreach (var entry in this)
item.Add(entry.Key, entry.Value);
return item;
}
}


Expand All @@ -261,7 +287,7 @@ public Rule(string pattern = "true", ProtectionPreset preset = ProtectionPreset.
Preset = preset;
Inherit = inherit;
}

/// <summary>
/// Gets or sets the pattern that determine the target components of the rule.
/// </summary>
Expand Down Expand Up @@ -564,5 +590,25 @@ public void Load(XmlDocument doc) {
}
}
}

/// <summary>
/// Clones this instance.
/// </summary>
/// <returns>A duplicated project.</returns>
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<string>(ProbePaths);
ret.PluginPaths = new List<string>(PluginPaths);
foreach (var module in this)
ret.Add(module.Clone());
foreach (var r in Rules)
ret.Rules.Add(r);
return ret;
}
}
}

0 comments on commit da99f43

Please sign in to comment.