public O2P(string url, string user, string password) { Url = url; User = user; Password = password; Setting = new PocoSetting(); }
public static IPocoClassGenerator GeneratePoco(MetaDataInfo metadata,PocoSetting setting=null) { if(string.IsNullOrEmpty(metadata.MetaDataAsString)) throw new XmlException("Metaddata is empty"); var generator = Create(metadata); return new PocoClassGeneratorCs(generator, setting??new PocoSetting() ); }
//container for all classes /// <summary> /// Constructor /// </summary> /// <param name="pocoGen"></param> /// <param name="setting"></param> private PocoClassGeneratorCs(IPocoGenerator pocoGen, PocoSetting setting) { PocoSetting = setting; _pocoGen = pocoGen; ClassList = pocoGen.GeneratePocoList(); CodeText = null; }
private static IPocoGenerator Create(MetaDataInfo metadata, PocoSetting setting) { if (string.IsNullOrEmpty(metadata.MetaDataAsString)) { throw new InvalidOperationException("No Metadata available"); } var metaDataVersion = metadata.MetaDataVersion; switch (metaDataVersion) { case ODataVersion.V4: return(new Poco(metadata, setting)); case ODataVersion.V1: case ODataVersion.V2: case ODataVersion.V3: return(new V3.Poco(metadata, setting)); //throw new NotImplementedException(); default: throw new NotSupportedException(string.Format("OData Version '{0}' is not supported", metaDataVersion)); } }
public O2P(PocoSetting setting = null) { Setting = setting ?? new PocoSetting(); // Source = Media.Http; ClassList = new List <ClassTemplate>(); MetaData = new MetaDataInfo(); }
/// <summary> /// cto initialization /// </summary> /// <param name="pocoSetting">Seting parameters of generating code</param> /// <param name="model">The model containing all classes </param> public AssemplyManager(PocoSetting pocoSetting, IDictionary <string, ClassTemplate> model) { _pocoSetting = pocoSetting; _model = model; AssemplyReference = new List <string>(); AddAssemply(DefaultAssemply);//add default assemplies AddAssemplyReferenceList(); }
//todo internal static async Task <IPocoGenerator> GenerateModel(OdataConnectionString connectionString, PocoSetting setting) { var metaData = await MetaDataReader.LoadMetadataAsync(connectionString); IPocoGenerator generator = Create(metaData, setting); return(generator); }
public static IPocoClassGenerator GeneratePoco(MetaDataInfo metadata, PocoSetting setting = null) { if (string.IsNullOrEmpty(metadata.MetaDataAsString)) { throw new XmlException("Metaddata is empty"); } var generator = Create(metadata); return(new PocoClassGeneratorCs(generator, setting ?? new PocoSetting())); }
/// <summary> /// Constructor /// </summary> /// <param name="pocoGen"></param> /// <param name="setting"></param> public PocoClassGeneratorCs(IPocoGenerator pocoGen, PocoSetting setting = null) { PocoSetting = setting ?? new PocoSetting(); _pocoGen = pocoGen; _classDictionary = new Dictionary<string, ClassTemplate>(); Template = new FluentCsTextTemplate(); var list = _pocoGen.GeneratePocoList(); //generate all classes from model if (list != null) foreach (var item in list) _classDictionary[item.Name] = item; //Console.WriteLine("PocoClassGeneratorCs constructor key: {0}", PocoSetting.AddKeyAttribute); CodeText = null; }
//container for all classes /// <summary> /// Constructor /// </summary> /// <param name="pocoGen"></param> /// <param name="setting"></param> public PocoClassGeneratorCs(IPocoGenerator pocoGen, PocoSetting setting = null) { PocoSetting = setting ?? new PocoSetting(); _pocoGen = pocoGen; //add jsonproperty to properties/classes that are renamed PocoSetting?.Attributes.Add("original"); //v3.2 //initialize AttributeFactory to use pocosetting.Attributes AttributeFactory.Default.Init(PocoSetting); ClassList = _pocoGen.GeneratePocoList(); //check reserved keywords ModelManager.RenameClasses(ClassList); Header = GetHeader() ?? ""; CodeText = null; }
/// <summary> /// Constructor /// </summary> /// <param name="pocoGen"></param> /// <param name="setting"></param> public PocoClassGeneratorCs(IPocoGenerator pocoGen, PocoSetting setting = null) { PocoSetting = setting ?? new PocoSetting(); _pocoGen = pocoGen; _classDictionary = new Dictionary <string, ClassTemplate>(); Template = new FluentCsTextTemplate(); var list = _pocoGen.GeneratePocoList(); //generate all classes from model if (list != null) { foreach (var item in list) { _classDictionary[item.Name] = item; } } //Console.WriteLine("PocoClassGeneratorCs constructor key: {0}", PocoSetting.AddKeyAttribute); CodeText = null; }
/// <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); }
/// <summary> /// Constructor /// </summary> /// <param name="pocoGen"></param> /// <param name="setting"></param> public PocoClassGeneratorCs(IPocoGenerator pocoGen, PocoSetting setting = null) { PocoSetting = setting ?? new PocoSetting(); //initialize AttributeFactory to use pocosetting.Attributes AttributeFactory.Default.Init(PocoSetting); _pocoGen = pocoGen; PocoModel = new Dictionary <string, ClassTemplate>(); Template = new FluentCsTextTemplate(); var list = _pocoGen.GeneratePocoList(); //generate all classes from model //check reserved keywords ModelManager.RenameClasses(list); if (list != null) { foreach (var item in list) { PocoModel[item.Name] = item; } } CodeText = null; }
/// <summary> /// Generate all attributes of the class /// </summary> /// <param name="setting"></param> /// <returns></returns> public List <string> GetAttributes(PocoSetting setting) { var list = new List <string>(); //[Table("depts")] if (setting.AddTableAttribute) { if (EntitySetName != "") { list.Add($"[Table(\"{EntitySetName}\")]"); } } //in future may be extra attributes or even custom user defined attributes //[DataContract] //if (setting.AddDataMemberAttribute) //{ // list.Add(string.Format("[{0}]", "DataContract")); //} return(list); }
public O2P() { Setting = new PocoSetting(); }
public PocoClassGeneratorVb(IPocoGenerator pocoFactory, PocoSetting setting) { throw new NotImplementedException(); }
public O2P(string url) { Url = url; Setting = new PocoSetting(); }
public static PocoClassGeneratorCs GenerateCsPocoClass(IPocoGenerator pocoGen, PocoSetting setting) { 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); }
/// <summary> /// /// </summary> /// <param name="url"> can be : Url , filename or xml data</param> /// <param name="setting"></param> //public O2P(Uri url, PocoSetting setting = null) //{ // ServiceUri = url; // Setting = setting ?? new PocoSetting(); // Source = Media.Http; // ClassList = new List<ClassTemplate>(); // MetaData = new MetaDataInfo(); //} //public O2P(Uri url, string user, string password, PocoSetting setting = null) // : this(url) //{ // User = user; // Password = password; //} //public O2P(string xmlContent, PocoSetting setting = null) //{ // _xmlContent = xmlContent; // Setting = setting ?? new PocoSetting(); // Source = Media.Http; // ClassList = new List<ClassTemplate>(); // MetaData = new MetaDataInfo(); //} public O2P( PocoSetting setting = null) { Setting = setting ?? new PocoSetting(); // Source = Media.Http; ClassList = new List<ClassTemplate>(); MetaData = new MetaDataInfo(); }
/// <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; }
/// <summary> /// Initialize in cto /// </summary> /// <param name="propertyTemplate"></param> /// <param name="pocoSetting"></param> public PropertyGenerator(PropertyTemplate propertyTemplate, PocoSetting pocoSetting) { _property = propertyTemplate; _setting = pocoSetting ?? new PocoSetting(); }