Example #1
0
        public DynamicModule DefineDynamicModule(string name)
        {
            ModuleBuilder moduleBuilder = builder.DefineDynamicModule(name, filename);
            DynamicModule module        = new DynamicModule(moduleBuilder, this);

            return(module);
        }
        private void BuildModule(ModuleDefinition moduleDefinition)
        {
            DynamicModule module = dynamicAssembly.DefineDynamicModule(moduleDefinition.Name);

            // TODO: Set user entry point.

            foreach (Resource resource in moduleDefinition.Resources)
            {
                BuildResource(module, resource);
            }

            foreach (TypeDefinition typeDefinition in moduleDefinition.Types)
            {
                // FIXME: Just for now, don't build generic types and other incomplete stuff.
                //        I've spent a lot of time on it already and there are some hard problems
                //        lurking.  Right now I just want a proof of concept.  -- Jeff.
                if (!typeDefinition.Name.Contains("Sample"))
                {
                    continue;
                }

                BuildType(module, typeDefinition);
            }

            metadataPass.Add(delegate
            {
                InitializeCustomAttributes(module.Builder.SetCustomAttribute, moduleDefinition.CustomAttributes);
            });
        }
Example #3
0
        public DynamicType(TypeBuilder builder, DynamicModule module)
        {
            this.builder = builder;
            this.module  = module;

            members = new MultiMap <string, object>();

            if (builder != null)
            {
                Assembly.RegisterDynamicType(builder, this);
            }
        }
        private void BuildType(DynamicModule module, TypeDefinition typeDefinition)
        {
            if (typeDefinition.Name == "<Module>")
            {
                return;
            }

            DynamicType type = module.DefineType(typeDefinition.FullName,
                                                 (System.Reflection.TypeAttributes)typeDefinition.Attributes, null,
                                                 (System.Reflection.Emit.PackingSize)typeDefinition.PackingSize, (int)typeDefinition.ClassSize);

            InitializeType(type, typeDefinition);
        }
 public DynamicResourceBuilder(DynamicModule module)
 {
     this.module = module;
 }
        private void BuildType(DynamicModule module, TypeDefinition typeDefinition)
        {
            if (typeDefinition.Name == "<Module>")
                return;

            DynamicType type = module.DefineType(typeDefinition.FullName,
                (System.Reflection.TypeAttributes)typeDefinition.Attributes, null,
                (System.Reflection.Emit.PackingSize)typeDefinition.PackingSize, (int)typeDefinition.ClassSize);

            InitializeType(type, typeDefinition);
        }
 private void BuildResource(DynamicModule module, Resource resource)
 {
     resource.Accept(new DynamicResourceBuilder(module));
 }
 public DynamicResourceBuilder(DynamicModule module)
 {
     this.module = module;
 }
 public DynamicModule DefineDynamicModule(string name)
 {
     ModuleBuilder moduleBuilder = builder.DefineDynamicModule(name, filename);
     DynamicModule module = new DynamicModule(moduleBuilder, this);
     return module;
 }
 private void BuildResource(DynamicModule module, Resource resource)
 {
     resource.Accept(new DynamicResourceBuilder(module));
 }