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

Commit

Permalink
Add TryGet method to runtime compression service
Browse files Browse the repository at this point in the history
  • Loading branch information
yck1509 committed Dec 21, 2014
1 parent 1e319eb commit e65e19f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Confuser.Core/Services/CompressionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ public CompressionService(ConfuserContext context) {
this.context = context;
}

/// <inheritdoc />
public MethodDef TryGetRuntimeDecompressor(ModuleDef module, Action<IDnlibDef> init) {
var decompressor = context.Annotations.Get<Tuple<MethodDef, List<IDnlibDef>>>(module, Decompressor);
if (decompressor == null)
return null;

foreach (IDnlibDef member in decompressor.Item2)
init(member);
return decompressor.Item1;
}

/// <inheritdoc />
public MethodDef GetRuntimeDecompressor(ModuleDef module, Action<IDnlibDef> init) {
Tuple<MethodDef, List<IDnlibDef>> decompressor = context.Annotations.GetOrCreate(module, Decompressor, m => {
Expand Down Expand Up @@ -123,6 +134,17 @@ public void SetProgress(long inSize, long outSize) {
/// </summary>
public interface ICompressionService {

/// <summary>
/// Gets the runtime decompression method in the module, or null if it's not yet injected.
/// </summary>
/// <param name="module">The module which the decompression method resides in.</param>
/// <param name="init">The initializing method for compression helper definitions.</param>
/// <returns>
/// The requested decompression method with signature 'static Byte[] (Byte[])',
/// or null if it hasn't been injected yet.
/// </returns>
MethodDef TryGetRuntimeDecompressor(ModuleDef module, Action<IDnlibDef> init);

/// <summary>
/// Gets the runtime decompression method in the module and inject if it does not exists.
/// </summary>
Expand Down

0 comments on commit e65e19f

Please sign in to comment.