Exemplo n.º 1
0
        public static PocoClassGeneratorCs GenerateCsPocoClass(IPocoGenerator pocoGen, PocoSetting?setting)
        {
            setting ??= new PocoSetting();
            //add jsonproperty to properties/classes that are renamed
            setting.Attributes.Add("original"); //v3.2


            //initialize AttributeFactory to use pocosetting.Attributes
            AttributeFactory.Default.Init(setting);

            var generator = new PocoClassGeneratorCs(pocoGen, setting);

            //filter model
            var generatorClassList = generator.ClassList;

            if (setting.Include?.Count > 0)
            {
                generator.ClassList = ModelFilter.FilterList(generatorClassList, setting.Include).ToList();
            }

            //change case
            if (setting.EntityNameCase != CaseEnum.None)
            {
                ModelChangeCase.RenameClasses(generatorClassList, setting.EntityNameCase);
            }

            //check reserved keywords
            ModelManager.RenameReservedWords(generatorClassList);
            generator.Header = generator.GetHeader() ?? "";
            //CodeText = null;
            return(generator);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Change case of class with its parent and related Property Type
        /// </summary>
        /// <param name="list">Class list</param>
        /// <param name="caseEnum">caseEnum</param>
        /// <returns></returns>
        public static ModelChangeCase RenameClasses(List <ClassTemplate> list, CaseEnum caseEnum)
        {
            var cc = new ModelChangeCase();

            if (caseEnum == CaseEnum.None)
            {
                return(cc);
            }

            //rename classes
            list.Update(c =>
            {
                c.Name = cc.RenameClass(c.Name, caseEnum);
                return(c);
            });
            //rename Parent
            list.Update(c =>
            {
                c.BaseType = cc.RenameParent(c.BaseType);
                return(c);
            });
            //rename properties type
            cc.RenamePropertiesType(list);
            return(cc);
        }