Ejemplo 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generate code PocoSetting setting =null, Language lang = Language.CS
        /// </summary>
        /// <returns></returns>
        //public PocoClassGeneratorCs Generate()
        //{
        //    PocoSetting setting = new PocoSetting();
        //    return Generate(setting);
        //}

        public PocoClassGeneratorCs Generate(PocoSetting setting, Language lang = Language.CS)
        {
            Console.WriteLine("metadatareader generate key: {0}", setting.AddKeyAttribute);
            if (MetaData == null)
            {
                MetaData = LoadMetaData();
            }
            IPocoGenerator       pocoFactory = PocoFactory.Create(MetaData);
            PocoClassGeneratorCs generator;

            if (lang == Language.CS)
            {
                generator = new PocoClassGeneratorCs(pocoFactory, setting);                     //.GeneratePoco();
            }
            else //vb ,java,...
            {
                throw new NotImplementedException();
            }
            return(generator);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Generate code PocoSetting setting =null, Language lang = Language.CS
        /// </summary>
        /// <returns></returns>
        //public PocoClassGeneratorCs Generate()
        //{
        //    PocoSetting setting = new PocoSetting();
        //    return Generate(setting);
        //}

        public PocoClassGeneratorCs Generate(PocoSetting setting, Language lang = Language.CS)
        {
            Console.WriteLine("metadatareader generate key: {0}", setting.AddKeyAttribute);
            if (MetaData == null) MetaData = LoadMetaData();
            IPocoGenerator pocoFactory = PocoFactory.Create(MetaData);
            PocoClassGeneratorCs generator;
            if (lang == Language.CS) generator= new PocoClassGeneratorCs(pocoFactory, setting); //.GeneratePoco();
            else //vb ,java,...
                throw new NotImplementedException();
            return generator;

        }