public Assembly Generate(AssemblyMetadata assemblyMetadata)
		{
			if(assemblyMetadata == null)
				throw new ArgumentNullException("assemblyMetadata");

			var assembly = GetAssemblyBuilder(assemblyMetadata.Name, true);
			var moduleName = string.Format("{0}_Module", assemblyMetadata.Name);
			var module = assembly.DefineDynamicModule(moduleName);

			this.GenerateTypes(module, assemblyMetadata.Types);

			return assembly;
		}
Beispiel #2
0
        public AssemblyMetadata Analyze(Assembly assembly)
        {
            AssemblyMetadata metadata = new AssemblyMetadata();
            Type[] types = SelectableTypes(assembly.GetTypes());
            foreach (Type type in types)
            {
                metadata.Classes.Add(ClassAnalyzer.Analyze(type));
            }

            IEnumerable<Attribute> attributes = (from a in assembly.GetCustomAttributes(true)
                                                 where typeof(Extension.Attribute).IsAssignableFrom(a.GetType())
                                                 select (Attribute)a);
            foreach (Attribute attribute in attributes)
            {
                metadata.Attributes.Add(attribute);
            }

            return metadata;
        }
Beispiel #3
0
		public Assembly CreateAssembly(Action<AssemblyMetadata> fn)
		{
			var asm = new AssemblyMetadata("test");
			fn(asm);
			return new DynamicAssemblyGenerator().Generate(asm);
		}