ICSharpCode.ILSpy.CSharpLanguage.DecompileType C# (CSharp) Method

DecompileType() public method

public DecompileType ( Mono.Cecil.TypeDefinition type, ITextOutput output, DecompilationOptions options ) : void
type Mono.Cecil.TypeDefinition
output ITextOutput
options DecompilationOptions
return void
		public override void DecompileType(TypeDefinition type, ITextOutput output, DecompilationOptions options)
		{
			AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: type);
			codeDomBuilder.AddType(type);
			RunTransformsAndGenerateCode(codeDomBuilder, output, options);
		}
		

Usage Example

示例#1
0
        public string Decompile(object @object)
        {
            if (@object == null) return String.Empty;
            Language l = new CSharpLanguage();

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

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

            return output.ToString();
        }
All Usage Examples Of ICSharpCode.ILSpy.CSharpLanguage::DecompileType