本文整理汇总了C#中IDnlibDef类的典型用法代码示例。如果您正苦于以下问题:C# IDnlibDef类的具体用法?C# IDnlibDef怎么用?C# IDnlibDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDnlibDef类属于命名空间,在下文中一共展示了IDnlibDef类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Analyze
internal void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, bool runAnalyzer)
{
if (def is TypeDef)
Analyze(service, context, parameters, (TypeDef)def);
else if (def is MethodDef)
Analyze(service, context, parameters, (MethodDef)def);
else if (def is FieldDef)
Analyze(service, context, parameters, (FieldDef)def);
else if (def is PropertyDef)
Analyze(service, context, parameters, (PropertyDef)def);
else if (def is EventDef)
Analyze(service, context, parameters, (EventDef)def);
else if (def is ModuleDef) {
var pass = parameters.GetParameter<string>(context, def, "password", null);
if (pass != null)
service.reversibleRenamer = new ReversibleRenamer(pass);
service.SetCanRename(def, false);
}
if (!runAnalyzer || parameters.GetParameter(context, def, "forceRen", false))
return;
foreach (IRenamer renamer in service.Renamers)
renamer.Analyze(context, service, parameters, def);
}
开发者ID:huoxudong125,项目名称:ConfuserEx,代码行数:25,代码来源:AnalyzePhase.cs
示例2: Evaluate
/// <inheritdoc />
public override object Evaluate(IDnlibDef definition) {
TypeDef type = definition as TypeDef;
if (type == null && definition is IMemberDef)
type = ((IMemberDef)definition).DeclaringType;
if (type == null)
return false;
string typeRegex = Arguments[0].Evaluate(definition).ToString();
var typeType = new StringBuilder();
if (type.IsEnum)
typeType.Append("enum ");
if (type.IsInterface)
typeType.Append("interface ");
if (type.IsValueType)
typeType.Append("valuetype ");
if (type.IsDelegate())
typeType.Append("delegate ");
if (type.IsAbstract)
typeType.Append("abstract ");
if (type.IsNested)
typeType.Append("nested ");
if (type.IsSerializable)
typeType.Append("serializable ");
return Regex.IsMatch(typeType.ToString(), typeRegex);
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:35,代码来源:IsTypeFunction.cs
示例3: Analyze
// i.e. Inter-Assembly References, e.g. InternalVisibleToAttributes
public void Analyze(ConfuserContext context, INameService service, IDnlibDef def)
{
var module = def as ModuleDefMD;
if (module == null) return;
MDTable table;
uint len;
// MemberRef
table = module.TablesStream.Get(Table.MemberRef);
len = table.Rows;
for (uint i = 1; i <= len; i++) {
MemberRef memberRef = module.ResolveMemberRef(i);
TypeDef declType = memberRef.DeclaringType.ResolveTypeDefThrow();
if (declType.Module != module && context.Modules.Contains((ModuleDefMD)declType.Module)) {
var memberDef = (IDnlibDef)declType.ResolveThrow(memberRef);
service.AddReference(memberDef, new MemberRefReference(memberRef, memberDef));
}
}
// TypeRef
table = module.TablesStream.Get(Table.TypeRef);
len = table.Rows;
for (uint i = 1; i <= len; i++) {
TypeRef typeRef = module.ResolveTypeRef(i);
TypeDef typeDef = typeRef.ResolveTypeDefThrow();
if (typeDef.Module != module && context.Modules.Contains((ModuleDefMD)typeDef.Module)) {
service.AddReference(typeDef, new TypeRefReference(typeRef, typeDef));
}
}
}
开发者ID:GavinHwa,项目名称:ConfuserEx,代码行数:34,代码来源:InterReferenceAnalyzer.cs
示例4: DoDisassemble
void DoDisassemble(IDnlibDef item, ITextOutput output, ReflectionDisassembler disassembler) {
if (item is ModuleDef) {
var module = (ModuleDef)item;
disassembler.WriteAssemblyReferences(module);
if (module.Assembly != null)
disassembler.WriteAssemblyHeader(module.Assembly);
output.WriteLine();
disassembler.WriteModuleHeader(module);
}
else if (item is TypeDef) {
disassembler.DisassembleType((TypeDef)item);
}
else if (item is MethodDef) {
disassembler.DisassembleMethod((MethodDef)item);
}
else if (item is FieldDef) {
disassembler.DisassembleField((FieldDef)item);
}
else if (item is PropertyDef) {
disassembler.DisassembleProperty((PropertyDef)item);
}
else if (item is EventDef) {
disassembler.DisassembleEvent((EventDef)item);
}
}
开发者ID:mamingxiu,项目名称:dnExplorer,代码行数:25,代码来源:CILLanguage.cs
示例5: Evaluate
/// <inheritdoc />
public override object Evaluate(IDnlibDef definition)
{
if (!(definition is IOwnerModule))
return false;
object name = Arguments[0].Evaluate(definition);
return ((IOwnerModule)definition).Module.Name == name.ToString();
}
开发者ID:GavinHwa,项目名称:ConfuserEx,代码行数:8,代码来源:ModuleFunction.cs
示例6: Analyze
// i.e. Inter-Assembly References, e.g. InternalVisibleToAttributes
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
{
var module = def as ModuleDefMD;
if (module == null) return;
// MemberRef/MethodSpec
var methods = module.GetTypes().SelectMany(type => type.Methods);
foreach(var methodDef in methods) {
foreach (var ov in methodDef.Overrides) {
ProcessMemberRef(context, service, module, ov.MethodBody);
ProcessMemberRef(context, service, module, ov.MethodDeclaration);
}
if (!methodDef.HasBody)
continue;
foreach (var instr in methodDef.Body.Instructions) {
if (instr.Operand is MemberRef || instr.Operand is MethodSpec)
ProcessMemberRef(context, service, module, (IMemberRef)instr.Operand);
}
}
// TypeRef
var table = module.TablesStream.Get(Table.TypeRef);
uint len = table.Rows;
for (uint i = 1; i <= len; i++) {
TypeRef typeRef = module.ResolveTypeRef(i);
TypeDef typeDef = typeRef.ResolveTypeDefThrow();
if (typeDef.Module != module && context.Modules.Contains((ModuleDefMD)typeDef.Module)) {
service.AddReference(typeDef, new TypeRefReference(typeRef, typeDef));
}
}
}
开发者ID:ReyAleman,项目名称:ConfuserEx,代码行数:34,代码来源:InterReferenceAnalyzer.cs
示例7: Apply
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.Skip(1).Reverse())
ApplyInfo(target, settings, i.Item2.Where(info => info.Condition != null), false);
ApplyInfo(target, settings, stack.Peek().Item2, false);
}
IDisposable result;
if (infoArray.Length != 0) {
var originalSettings = this.settings;
// the settings that would apply to members
ApplyInfo(target, settings, infoArray, false);
this.settings = new ProtectionSettings(settings);
// the settings that would apply to itself
ApplyInfo(target, settings, infoArray, true);
stack.Push(Tuple.Create(originalSettings, infoArray));
result = new PopHolder(this);
}
else
result = null;
ProtectionParameters.SetParameters(context, target, settings);
return result;
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:35,代码来源:ObfAttrMarker.cs
示例8: Evaluate
/// <inheritdoc />
public override object Evaluate(IDnlibDef definition) {
var member = definition as IMemberDef;
if (member == null)
return false;
var declType = ((IMemberDef)definition).DeclaringType;
while (declType != null) {
if (!declType.IsPublic)
return false;
declType = declType.DeclaringType;
}
if (member is MethodDef)
return ((MethodDef)member).IsPublic;
if (member is FieldDef)
return ((FieldDef)member).IsPublic;
if (member is PropertyDef)
return ((PropertyDef)member).IsPublic();
if (member is EventDef)
return ((EventDef)member).IsPublic();
if (member is TypeDef)
return ((TypeDef)member).IsPublic || ((TypeDef)member).IsNestedPublic;
throw new NotSupportedException();
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:26,代码来源:IsPublicFunction.cs
示例9: MarkMember
/// <inheritdoc />
protected internal override void MarkMember(IDnlibDef member, ConfuserContext context)
{
ModuleDef module = ((IMemberRef)member).Module;
var stack = context.Annotations.Get<ProtectionSettingsStack>(module, ModuleSettingsKey);
using (stack.Apply(member, Enumerable.Empty<ProtectionSettingsInfo>()))
return;
}
开发者ID:RSchwoerer,项目名称:ConfuserEx,代码行数:8,代码来源:ObfAttrMarker.cs
示例10: Evaluate
/// <inheritdoc />
public override object Evaluate(IDnlibDef definition)
{
if (!(definition is IMemberDef) || ((IMemberDef)definition).DeclaringType == null)
return false;
object fullName = Arguments[0].Evaluate(definition);
return ((IMemberDef)definition).DeclaringType.FullName == fullName.ToString();
}
开发者ID:89sos98,项目名称:ConfuserEx,代码行数:8,代码来源:DeclTypeFunction.cs
示例11: Run
public CodeViewData Run(IDnlibDef item, CancellationToken token) {
var builder = CreateBuilder(item, token);
if (builder == null)
return new CodeViewData("");
builder.RunTransformations();
var output = new CodeViewOutput();
builder.GenerateCode(output);
return output.GetResult();
}
开发者ID:mamingxiu,项目名称:dnExplorer,代码行数:9,代码来源:CSharpLanguage.cs
示例12: Analyze
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) {
var method = def as MethodDef;
if (method == null || !method.HasBody)
return;
// When a ldtoken instruction reference a definition,
// most likely it would be used in reflection and thus probably should not be renamed.
// Also, when ToString is invoked on enum,
// the enum should not be renamed.
for (int i = 0; i < method.Body.Instructions.Count; i++) {
Instruction instr = method.Body.Instructions[i];
if (instr.OpCode.Code == Code.Ldtoken) {
if (instr.Operand is MemberRef) {
IMemberForwarded member = ((MemberRef)instr.Operand).ResolveThrow();
if (context.Modules.Contains((ModuleDefMD)member.Module))
service.SetCanRename(member, false);
}
else if (instr.Operand is IField) {
FieldDef field = ((IField)instr.Operand).ResolveThrow();
if (context.Modules.Contains((ModuleDefMD)field.Module))
service.SetCanRename(field, false);
}
else if (instr.Operand is IMethod) {
var im = (IMethod)instr.Operand;
if (!im.IsArrayAccessors()) {
MethodDef m = im.ResolveThrow();
if (context.Modules.Contains((ModuleDefMD)m.Module))
service.SetCanRename(method, false);
}
}
else if (instr.Operand is ITypeDefOrRef) {
if (!(instr.Operand is TypeSpec)) {
TypeDef type = ((ITypeDefOrRef)instr.Operand).ResolveTypeDefThrow();
if (context.Modules.Contains((ModuleDefMD)type.Module) &&
HandleTypeOf(context, service, method, i)) {
var t = type;
do {
DisableRename(service, t, false);
t = t.DeclaringType;
} while (t != null);
}
}
}
else
throw new UnreachableException();
}
else if ((instr.OpCode.Code == Code.Call || instr.OpCode.Code == Code.Callvirt) &&
((IMethod)instr.Operand).Name == "ToString") {
HandleEnum(context, service, method, i);
}
else if (instr.OpCode.Code == Code.Ldstr) {
TypeDef typeDef = method.Module.FindReflection((string)instr.Operand);
if (typeDef != null)
service.AddReference(typeDef, new StringTypeReference(instr, typeDef));
}
}
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:57,代码来源:LdtokenEnumAnalyzer.cs
示例13: CreateBuilder
AstBuilder CreateBuilder(IDnlibDef item, CancellationToken token) {
ModuleDef moduleDef;
DecompilerContext ctx;
AstBuilder builder;
if (item is ModuleDef) {
var def = (ModuleDef)item;
moduleDef = def;
builder = new AstBuilder(ctx = new DecompilerContext(moduleDef) { CancellationToken = token });
builder.AddAssembly(def, true);
}
else if (item is TypeDef) {
var def = (TypeDef)item;
moduleDef = def.Module;
builder = new AstBuilder(ctx = new DecompilerContext(moduleDef) { CancellationToken = token });
builder.DecompileMethodBodies = false;
ctx.CurrentType = def;
builder.AddType(def);
}
else if (item is MethodDef) {
var def = (MethodDef)item;
moduleDef = def.Module;
builder = new AstBuilder(ctx = new DecompilerContext(moduleDef) { CancellationToken = token });
ctx.CurrentType = def.DeclaringType;
builder.AddMethod(def);
}
else if (item is FieldDef) {
var def = (FieldDef)item;
moduleDef = def.Module;
builder = new AstBuilder(ctx = new DecompilerContext(moduleDef) { CancellationToken = token });
ctx.CurrentType = def.DeclaringType;
builder.AddField(def);
}
else if (item is PropertyDef) {
var def = (PropertyDef)item;
moduleDef = def.Module;
builder = new AstBuilder(ctx = new DecompilerContext(moduleDef) { CancellationToken = token });
ctx.CurrentType = def.DeclaringType;
builder.AddProperty(def);
}
else if (item is EventDef) {
var def = (EventDef)item;
moduleDef = def.Module;
builder = new AstBuilder(ctx = new DecompilerContext(moduleDef) { CancellationToken = token });
ctx.CurrentType = def.DeclaringType;
builder.AddEvent(def);
}
else
return null;
ctx.Settings = new DecompilerSettings {
UsingDeclarations = false
};
return builder;
}
开发者ID:mamingxiu,项目名称:dnExplorer,代码行数:56,代码来源:CSharpLanguage.cs
示例14: Mark
/// <inheritdoc />
public void Mark(IDnlibDef member)
{
if (member == null)
throw new ArgumentNullException("member");
if (member is ModuleDef)
throw new ArgumentException("New ModuleDef cannot be marked.");
if (IsMarked(member)) // avoid double marking
return;
marker.MarkMember(member, context);
}
开发者ID:89sos98,项目名称:ConfuserEx,代码行数:12,代码来源:MarkerService.cs
示例15: Evaluate
/// <inheritdoc />
public override object Evaluate(IDnlibDef definition) {
if (definition is TypeDef) {
string regex = Arguments[0].Evaluate(definition).ToString();
return Regex.IsMatch(definition.Name, regex);
}
if (definition is IMemberDef && ((IMemberDef)definition).DeclaringType != null) {
string regex = Arguments[0].Evaluate(definition).ToString();
return Regex.IsMatch(((IMemberDef)definition).DeclaringType.Name, regex);
}
return false;
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:12,代码来源:MatchFunction.cs
示例16: Analyze
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
{
if (def is TypeDef)
Analyze(context, service, (TypeDef)def, parameters);
else if (def is MethodDef)
Analyze(context, service, (MethodDef)def, parameters);
else if (def is PropertyDef)
Analyze(context, service, (PropertyDef)def, parameters);
else if (def is FieldDef)
Analyze(context, service, (FieldDef)def, parameters);
}
开发者ID:RSchwoerer,项目名称:ConfuserEx,代码行数:11,代码来源:JsonAnalyzer.cs
示例17: Display
public void Display(IDnlibDef item = null) {
treeView.App.DockArea.DockWindows[DockState.DockBottom].BringToFront();
Show(treeView.App.DockArea, DockState.DockBottom);
if (item != null) {
if (item is ModuleDef && ((ModuleDef)item).Assembly != null)
item = ((ModuleDef)item).Assembly;
treeView.Nodes.Add(new MultipleAnalysesModel(item, GetChildren(item)).ToNode());
}
}
开发者ID:mamingxiu,项目名称:dnExplorer,代码行数:11,代码来源:Analyzer.cs
示例18: Analyze
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
{
var module = def as ModuleDef;
if (module == null) return;
string asmName = module.Assembly.Name.String;
if (!string.IsNullOrEmpty(module.Assembly.Culture) &&
asmName.EndsWith(".resources")) {
// Satellite assembly
var satellitePattern = new Regex(string.Format("^(.*)\\.{0}\\.resources$", module.Assembly.Culture));
string nameAsmName = asmName.Substring(0, asmName.Length - ".resources".Length);
ModuleDef mainModule = context.Modules.SingleOrDefault(mod => mod.Assembly.Name == nameAsmName);
if (mainModule == null) {
context.Logger.ErrorFormat("Could not find main assembly of satellite assembly '{0}'.", module.Assembly.FullName);
throw new ConfuserException(null);
}
string format = "{0}." + module.Assembly.Culture + ".resources";
foreach (Resource res in module.Resources) {
Match match = satellitePattern.Match(res.Name);
if (!match.Success)
continue;
string typeName = match.Groups[1].Value;
TypeDef type = mainModule.FindReflectionThrow(typeName);
if (type == null) {
context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName);
continue;
}
service.ReduceRenameMode(type, RenameMode.ASCII);
service.AddReference(type, new ResourceReference(res, type, format));
}
}
else {
string format = "{0}.resources";
foreach (Resource res in module.Resources) {
Match match = ResourceNamePattern.Match(res.Name);
if (!match.Success)
continue;
string typeName = match.Groups[1].Value;
if (typeName.EndsWith(".g")) // WPF resources, ignore
continue;
TypeDef type = module.FindReflection(typeName);
if (type == null) {
context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName);
continue;
}
service.ReduceRenameMode(type, RenameMode.ASCII);
service.AddReference(type, new ResourceReference(res, type, format));
}
}
}
开发者ID:MulleDK19,项目名称:ConfuserEx,代码行数:53,代码来源:ResourceAnalyzer.cs
示例19: Evaluate
/// <inheritdoc />
public override object Evaluate(IDnlibDef definition)
{
string name = Arguments[0].Evaluate(definition).ToString();
if (!(definition is TypeDef))
return false;
var type = (TypeDef)definition;
if (type.InheritsFrom(name) || type.Implements(name))
return true;
return false;
}
开发者ID:cybercircuits,项目名称:ConfuserEx,代码行数:13,代码来源:InheritsFunction.cs
示例20: Mark
/// <inheritdoc />
public void Mark(IDnlibDef member, ConfuserComponent parentComp) {
if (member == null)
throw new ArgumentNullException("member");
if (member is ModuleDef)
throw new ArgumentException("New ModuleDef cannot be marked.");
if (IsMarked(member)) // avoid double marking
return;
marker.MarkMember(member, context);
if (parentComp != null)
helperParents[member] = parentComp;
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:13,代码来源:MarkerService.cs
注:本文中的IDnlibDef类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论