public string CreateTypeScript(string comment=null) { if (this._dotNet2TS != null) { this._dotNet2TS.newClientTypeAdded -= _dotnet2TS_newClientTypeAdded; } this._dotNet2TS = new DotNet2TS(this._serviceContainer); this._dotNet2TS.newClientTypeAdded += _dotnet2TS_newClientTypeAdded; _sb.Length = 0; if (!string.IsNullOrWhiteSpace(comment)) { TypeScriptHelper.addComment(_sb, comment); } this.WriteStringLine(@"import collMOD = RIAPP.MOD.collection;"); this.WriteStringLine(@"import dbMOD = RIAPP.MOD.db;"); this.WriteLine(); this.processMethodArgs(); string isvcMethods = this.createISvcMethods(); //create typed Lists and Dictionaries string listTypes = this.createClientTypes(); //get interface declarations for all client types string sbInterfaceDefs = this._dotNet2TS.GetInterfaceDeclarations(); if (!string.IsNullOrWhiteSpace(sbInterfaceDefs)) { this.WriteStringLine(@"//******BEGIN INTERFACE REGION******"); this.WriteStringLine(sbInterfaceDefs); this.WriteStringLine(@"//******END INTERFACE REGION******"); this.WriteLine(); } if (!string.IsNullOrWhiteSpace(isvcMethods)) { this.WriteStringLine(isvcMethods); this.WriteLine(); } if (!string.IsNullOrWhiteSpace(listTypes)) { this.WriteStringLine(@"//******BEGIN LISTS REGION******"); this.WriteStringLine(listTypes); this.WriteStringLine(@"//******END LISTS REGION******"); this.WriteLine(); } //this.WriteStringLine(this.createQueryNames()); ComplexTypeBuilder ctbuilder = new ComplexTypeBuilder(this._dotNet2TS); this._metadata.dbSets.ForEach((dbSetInfo) => { dbSetInfo.fieldInfos.ForEach((fieldInfo) => { if (fieldInfo.fieldType == FieldType.Object) { ctbuilder.CreateComplexType(dbSetInfo, fieldInfo, 0); } }); }); string complexTypes = ctbuilder.GetComplexTypes(); if (!string.IsNullOrWhiteSpace(complexTypes)) { this.WriteStringLine(@"//******BEGIN COMPLEX TYPES REGION*****"); this.WriteStringLine(complexTypes); this.WriteStringLine(@"//******END COMPLEX TYPES REGION******"); this.WriteLine(); } this._metadata.dbSets.ForEach((dbSetInfo) => { this.WriteStringLine(this.createEntityType(dbSetInfo)); this.WriteLine(); this.WriteStringLine(this.createDbSetType(dbSetInfo)); this.WriteLine(); }); this.WriteStringLine(this.createIAssocs()); this.WriteLine(); this.WriteStringLine(this.createDbContextType()); this.WriteLine(); return _sb.ToString(); }
public ComplexTypeBuilder(DotNet2TS dotNet2TS) { this._dotNet2TS = dotNet2TS; this._complexTypes = new Dictionary<string, string>(); }