Ejemplo n.º 1
0
 public override void Decompile(ICSharpCode.ILSpy.Language language, ITextOutput output, ICSharpCode.ILSpy.DecompilationOptions options)
 {
     //Switches on the token
     switch (_tokenProvider.MetadataToken.TokenType)
     {
         case TokenType.Module:
             language.DecompileModule((ModuleDefinition)_tokenProvider, output, options);
             break;
         case TokenType.Assembly:
             language.WriteCommentLine(output, ((AssemblyNameReference)_tokenProvider).FullName);
             break;
         case TokenType.TypeDef:
             language.DecompileType((TypeDefinition)_tokenProvider, output, options);
             break;
         case TokenType.Field:
             language.DecompileField((FieldDefinition)_tokenProvider, output, options);
             break;
         case TokenType.Method:
             language.DecompileMethod((MethodDefinition)_tokenProvider, output, options);
             break;
         case TokenType.Event:
             language.DecompileEvent((EventDefinition)_tokenProvider, output, options);
             break;
         case TokenType.Property:
             language.DecompileProperty((PropertyDefinition)_tokenProvider, output, options);
             break;
         case TokenType.MemberRef:
             var memberRef = (MemberReference)_tokenProvider;
             if (memberRef.DeclaringType != null && memberRef.DeclaringType is GenericInstanceType)
             {
                 var giType = (GenericInstanceType)memberRef.DeclaringType;
                 var type = giType.ElementType.Resolve();
                 var memberDef = type.Fields.Cast<IMemberDefinition>()
                     .Concat(type.Methods)
                     .Concat(type.Properties)
                     .Concat(type.Events)
                     .FirstOrDefault(m => m.Name == memberRef.Name);
                 if (memberDef != null)
                     new ILEditTreeNode(memberDef, true).Decompile(language, output, options);
             }
             break;
         default:
             language.WriteCommentLine(output, (string)this.Text);
             break;
     }
 }