Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <summary>
        /// ctor
        /// </summary>
        static DynamicTypeBuilder()
        {
            var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(GuidExtend.NewGuid()),
                                                                        AssemblyBuilderAccess.Run);

            _moduleBuilder = assemblyBuilder.DefineDynamicModule("DynamicFormModule");
        }