Beispiel #1
0
        public AssemblyBuilder(AssemblyDefinition assembly, ReferenceResolver resolver)
        {
            if(assembly == null)
                throw new ArgumentNullException("assembly");
            if(resolver == null)
                throw new ArgumentNullException("resolver");

            Assembly = CloneAssembly(assembly);

            this.resolver = resolver;

            resolver.Module = Assembly.MainModule;
            typeBuilder = new TypeBuilder(Assembly.MainModule, resolver);
        }
Beispiel #2
0
        protected override void Process()
        {
            _assemblies = Context.GetAssemblies();
            _mergedAssembly = CloneAssemblyDefinition(_assemblies[0],/* "merged_" +*/ _assemblies[0].Name.Name);

            _resolver = new ReferenceResolver(_mergedAssembly.MainModule, t =>
            {
                return !_assemblies.Any(a => a.MainModule.GetAllTypes().Contains(t.Resolve()));
            });

            _resolver.Action = t =>
            {
                var resolved = t.Resolve();
                if (t.IsNested)
                {
                    TypeReference declaringType = _resolver.Action(resolved.DeclaringType);
                    return declaringType.Resolve().InjectNestedType(resolved, _resolver);
                }
                else
                    return _mergedAssembly.MainModule.InjectType(resolved, _resolver);
            };
        }
Beispiel #3
0
 public static ReferenceResolver GetDefaultResolver(ModuleDefinition module)
 {
     ReferenceResolver resolver = new ReferenceResolver(module, Helper.IsCore);
     return resolver;
 }