public IDisposable Apply(IDnlibDef target, IEnumerable <ProtectionSettingsInfo> infos) { ProtectionSettings settings; if (this.settings == null) { settings = new ProtectionSettings(); } else { settings = new ProtectionSettings(this.settings); } var infoArray = infos.ToArray(); if (stack.Count > 0) { foreach (var i in stack.Reverse()) { ApplyInfo(target, settings, i.Item2, ApplyInfoType.ParentInfo); } } IDisposable result; if (infoArray.Length != 0) { var originalSettings = this.settings; // the settings that would apply to members ApplyInfo(target, settings, infoArray, ApplyInfoType.CurrentInfoInherits); this.settings = new ProtectionSettings(settings); // the settings that would apply to itself ApplyInfo(target, settings, infoArray, ApplyInfoType.CurrentInfoOnly); stack.Push(Tuple.Create(originalSettings, infoArray)); result = new PopHolder(this); } else { result = null; } ProtectionParameters.SetParameters(context, target, settings); return(result); }
public IDisposable Apply(IDnlibDef target, IEnumerable<ProtectionSettingsInfo> infos) { ProtectionSettings settings; if (this.settings == null) settings = new ProtectionSettings(); else settings = new ProtectionSettings(this.settings); var infoArray = infos.ToArray(); if (stack.Count > 0) { foreach (var i in stack.Reverse()) ApplyInfo(target, settings, i.Item2, ApplyInfoType.ParentInfo); } IDisposable result; if (infoArray.Length != 0) { var originalSettings = this.settings; // the settings that would apply to members ApplyInfo(target, settings, infoArray, ApplyInfoType.CurrentInfoInherits); this.settings = new ProtectionSettings(settings); // the settings that would apply to itself ApplyInfo(target, settings, infoArray, ApplyInfoType.CurrentInfoOnly); stack.Push(Tuple.Create(originalSettings, infoArray)); result = new PopHolder(this); } else result = null; ProtectionParameters.SetParameters(context, target, settings); return result; }