DecompileProperty() public method

public DecompileProperty ( Mono.Cecil.PropertyDefinition property, ITextOutput output, DecompilationOptions options ) : void
property Mono.Cecil.PropertyDefinition
output ITextOutput
options DecompilationOptions
return void
コード例 #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;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: CompilerKit/CodeWalk
 private void DecompileProperty(Language language, PropertyDefinition property, ITextOutput output, DecompilationOptions options)
 {
     language.DecompileProperty(property, output, options);
 }
コード例 #3
0
        public string Decompile(string language, object o)
        {
            if (o == null)
            {
                return(String.Empty);
            }
            Language l = CreateLanguage(language);

            if (l == null)
            {
                return(String.Format("Can't create language: {0}", language));
            }

            ITextOutput          output  = new RtfTextOutput();
            DecompilationOptions options = new DecompilationOptions();

            if (o is AssemblyDefinition)
            {
                l.DecompileAssembly((AssemblyDefinition)o, output, options);
            }
            else if (o is TypeDefinition)
            {
                l.DecompileType((TypeDefinition)o, output, options);
            }
            else if (o is MethodDefinition)
            {
                l.DecompileMethod((MethodDefinition)o, output, options);
            }
            else if (o is FieldDefinition)
            {
                l.DecompileField((FieldDefinition)o, output, options);
            }
            else if (o is PropertyDefinition)
            {
                l.DecompileProperty((PropertyDefinition)o, output, options);
            }
            else if (o is EventDefinition)
            {
                l.DecompileEvent((EventDefinition)o, output, options);
            }
            else if (o is AssemblyNameReference)
            {
                output.Write("// Assembly Reference ");
                output.WriteDefinition(o.ToString(), null);
                output.WriteLine();
            }
            else if (o is ModuleReference)
            {
                output.Write("// Module Reference ");
                output.WriteDefinition(o.ToString(), null);
                output.WriteLine();
            }
            else
            {
                output.Write(String.Format("// {0} ", o.GetType().Name));
                output.WriteDefinition(o.ToString(), null);
                output.WriteLine();
            }

            return(output.ToString());
        }