Пример #1
0
            public static List <Type> CreateClassProperties(string moduleName, IEnumerable <JProperty> properties, TypeBuilder typeBuilder, List <Type> listType)
            {
                foreach (var e in properties)
                {
                    string pname = e.Name;

                    if (e.Value.Count() == 0)
                    {
                        string ptype = "System.String";
                        DynamicType.CreateProperty(typeBuilder, pname, Type.GetType(ptype));
                    }
                    else
                    {
                        TypeBuilder tbParent = DynamicType.CreateType(DynamicType.modBuilder, pname);
                        listType = CreateClassProperties(moduleName + e.Name, e.Value.Children <JProperty>(), tbParent, listType);
                        DynamicType.CreateProperty(typeBuilder, pname, tbParent.AsType());
                    }
                }

                var finalType = DynamicType.modBuilder.GetType(moduleName);

                finalType = typeBuilder.CreateType();
                listType.Add(finalType);

                return(listType);
            }