/// <summary> /// 创建类型 /// </summary> /// <param name="fields"></param> /// <returns></returns> public static Type CompileType(this IEnumerable <DynamicGenerateObject> fields) { string className = "D_" + GuidExtend.NewGuid(); var typeBuilder = CreateTypeBuilder(className); foreach (var fieldItem in fields) { CreateProperty(typeBuilder, fieldItem); } var objectType = typeBuilder.CreateType(); return(objectType); }
/// <summary> /// ctor /// </summary> static DynamicTypeBuilder() { var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(GuidExtend.NewGuid()), AssemblyBuilderAccess.Run); _moduleBuilder = assemblyBuilder.DefineDynamicModule("DynamicFormModule"); }