Exemplo n.º 1
0
        public static ModuleDefinition StickyReadModule(string fileName)
        {
            // Warning.
            // Verify that there are no calls to Mono.Cecil.ModuleDefinition.ReadModule(fileName);
            // in Campy!
            string p = Path.GetDirectoryName(fileName);
            // There is no ReaderParameter set. Create one.
            var resolver = new StickyAssemblyResolver();

            resolver.AddSearchDirectory(p);
            var metadata_resolver = new StickyMetadataResolver(resolver);

            Mono.Cecil.ModuleDefinition md = Mono.Cecil.ModuleDefinition.ReadModule(
                fileName,
                new ReaderParameters {
                AssemblyResolver = resolver, MetadataResolver = metadata_resolver
            });
            return(md);
        }
Exemplo n.º 2
0
        public static ModuleDefinition StickyReadModule(string fileName, ReaderParameters parameters)
        {
            StickyAssemblyResolver resolver = null;

            if (parameters.AssemblyResolver == null)
            {
                resolver = new StickyAssemblyResolver();
            }
            else if (parameters.AssemblyResolver as StickyAssemblyResolver == null)
            {
                throw new Exception("You must use StickyAssemblyResolver in StickyReadModule.");
            }
            else
            {
                resolver = (StickyAssemblyResolver)parameters.AssemblyResolver;
            }

            string p = Path.GetDirectoryName(fileName);

            resolver.AddSearchDirectory(p);


            StickyMetadataResolver metadata_resolver = null;

            if (parameters.MetadataResolver == null)
            {
                metadata_resolver = new StickyMetadataResolver(resolver);
            }
            else if (parameters.MetadataResolver as StickyMetadataResolver == null)
            {
                throw new Exception("You must use StickyMetadataResolver in StickyReadModule.");
            }
            else
            {
                metadata_resolver = (StickyMetadataResolver)parameters.MetadataResolver;
            }

            parameters.AssemblyResolver = resolver;
            parameters.MetadataResolver = metadata_resolver;

            Mono.Cecil.ModuleDefinition md = Mono.Cecil.ModuleDefinition.ReadModule(fileName, parameters);
            return(md);
        }
Exemplo n.º 3
0
 public StickyMetadataResolver(IAssemblyResolver assemblyResolver)
 {
     assembly_resolver = (StickyAssemblyResolver)assemblyResolver;
     assembly_resolver.MetadataResolver = this;
 }