コード例 #1
0
		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;
		}
コード例 #2
0
ファイル: AssemblyAnalyzer.cs プロジェクト: trentcioran/karma
        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;
        }
コード例 #3
0
ファイル: BaseFixture.cs プロジェクト: juankakode/Mek.CodeGen
		public Assembly CreateAssembly(Action<AssemblyMetadata> fn)
		{
			var asm = new AssemblyMetadata("test");
			fn(asm);
			return new DynamicAssemblyGenerator().Generate(asm);
		}