public override CRflModel Expand(CRflModel aModel) { var aTmpModel = aModel; bool aInludeFound; do { var aIncludes = this.ModelInterpreter.GetIncludes(aTmpModel).ToArray(); if (aIncludes.Length > 0) { var aInclude = aIncludes.First(); var aIncludeRow = aInclude.Item1; var aIncludeFileInfo = aInclude.Item2; var aIncludedModelUnexpanded = this.ModelInterpreter.NewIncludedModel(aIncludeFileInfo); var aInclduedModelExpanded = this.Expand(aIncludedModelUnexpanded); var aRows1 = aTmpModel.Rows.TakeWhile(aRow => !object.ReferenceEquals(aIncludeRow, aRow)); var aRows2 = aInclduedModelExpanded.Rows; var aRows3 = aTmpModel.Rows.Reverse().TakeWhile(aRow => !object.ReferenceEquals(aIncludeRow, aRow)).Reverse(); var aRows4 = aRows1.Concat(aRows2).Concat(aRows3); var aRows = aRows4.ToArray(); aTmpModel = new CRflModel(aTmpModel.ModelInterpreter, aModel.FileInfo, aRows); aInludeFound = true; } else { aInludeFound = false; } }while (aInludeFound); return(aTmpModel); }
public override CRflModel Expand(CRflModel aModel) { var aModelInterpreter = this.ModelInterpreter; var aTyps = aModel.Typs; var aEntityObjectProperties = from aTyp in aTyps from aProperty in aTyp.NamedProperties where aModelInterpreter.GetIsObject(this.ModelInterpreter.GetReturnTyp(aProperty)) select aProperty; var aR1NCProperties = from aProperty in aEntityObjectProperties where aModelInterpreter.GetCardinality(aProperty) == CCardinalityEnum.R1NC select aProperty; var aR1NCFkRows = from aProperty in aR1NCProperties from aRow in aModelInterpreter.NewR1NCForeignKeyRows(aProperty) select aRow ; var aR1NCRevereRows = from aProperty in aR1NCProperties from aRow in aModelInterpreter.NewR1NCReverseNavigationRows(aProperty) select aRow ; var aR11CProperties = from aProperty in aEntityObjectProperties where aModelInterpreter.GetCardinality(aProperty) == CCardinalityEnum.R11C select aProperty; var aR11CFkRows = (from aProperty in aR11CProperties from aRow in aModelInterpreter.NewR11CForeignKeyRows(aProperty) select aRow); var aR11CReverseRows = from aProperty in aR11CProperties from aRow in aModelInterpreter.NewR11CReverseNavigationRows(aProperty) select aRow; var aOrgRows = aModel.Rows; var aNewRows = aR1NCFkRows.Concat(aR1NCRevereRows).Concat(aR11CFkRows).Concat(aR11CReverseRows).Concat(aOrgRows); var aOutModel = new CRflModel(aModelInterpreter, aModel.FileInfo, aNewRows); return(aOutModel); }
public CGenUnitTest(FileInfo aSequenceFileInfo, DirectoryInfo aTestCasesDirectoryInfo) { this.SequenceFileInfo = aSequenceFileInfo; this.TestCasesDirectoryInfo = aTestCasesDirectoryInfo; this.TestSequence = CRflModel.NewFromTextFile(this.TestModelInterperter, this.SequenceFileInfo); this.OutReportFileInfo = new FileInfo(this.SequenceFileInfo.FullName + "-report.xdl"); }
private IEnumerable <CodeTypeMember> NewSchemaMembers(CRflModel aModel, string aSchemaClassName) { yield return(this.NewSchemaConstructor(aModel)); foreach (var aMember in this.NewSchemaSingletonMembers(aModel, aSchemaClassName)) { yield return(aMember); } }
public override CRflModel Expand(CRflModel aModel) { var aTmpModel = aModel; foreach (var aExpander in this.ChainedExpanders) { aTmpModel = aExpander.Expand(aTmpModel); } return(aTmpModel); }
private IEnumerable <CodeTypeDeclaration> NewSchemaClasses(CRflModel aModel) { var aSchemaClsNme = this.Tok.GetSchemaClassName(this.ModelInterpreter.GetSchema(aModel)); if (aSchemaClsNme.Length > 0) { var aCdSchemaClassDecl = new CodeTypeDeclaration(); aCdSchemaClassDecl.Name = aSchemaClsNme; aCdSchemaClassDecl.BaseTypes.Add(this.CodeDomBuilder.NewCodeTypeRef <CSchema>()); aCdSchemaClassDecl.Members.AddRange(this.NewSchemaMembers(aModel, aSchemaClsNme).ToArray()); yield return(aCdSchemaClassDecl); } }
private IEnumerable <CodeTypeMember> NewSchemaSingletonMembers(CRflModel aModel, string aSchemaClassName) { var aCdPrpNme = this.Tok.Dom_P_Singleton_Nme; var aFieldName = this.Tok.GetFieldName(aCdPrpNme); var aCdFieldType = new CodeTypeReference(aSchemaClassName); var aCdFieldDecl = new CodeMemberField(aCdFieldType, aFieldName); aCdFieldDecl.Attributes = MemberAttributes.Public | MemberAttributes.Static ; aCdFieldDecl.InitExpression = new CodeObjectCreateExpression(aCdFieldType); var aCdPrpDecl = new CodeMemberProperty(); aCdPrpDecl.Name = aCdPrpNme; aCdPrpDecl.Type = aCdFieldType; aCdPrpDecl.Attributes = MemberAttributes.Public | MemberAttributes.Static ; var aCdTypeRefExp = new CodeTypeReferenceExpression(aSchemaClassName); var aCdFldRefExp = new CodeFieldReferenceExpression(aCdTypeRefExp, aFieldName); var aRetStm = new CodeMethodReturnStatement(aCdFldRefExp); aCdPrpDecl.GetStatements.Add(aRetStm); var aCdFieldTypeRef = new CodeTypeReferenceExpression(aSchemaClassName); var aGetSchemaMthNme = this.Tok.GetGetSchemaFuncName(); var aCdGetSchemaMth = new CodeMemberMethod(); aCdGetSchemaMth.Name = aGetSchemaMthNme; aCdGetSchemaMth.ReturnType = this.CodeDomBuilder.NewCodeTypeRef <CSchema>(); aCdGetSchemaMth.Attributes = MemberAttributes.Static | MemberAttributes.Public ; aCdGetSchemaMth.Statements.Add(new CodeMethodReturnStatement(aCdFldRefExp)); yield return(aCdFieldDecl); yield return(aCdPrpDecl); yield return(aCdGetSchemaMth); }
private CodeConstructor NewSchemaConstructor(CRflModel aModel) { var aCtor = new CodeConstructor(); var aEnumTyps = this.ModelInterpreter.GetEnumTyps(aModel); var aRegisterEnumTypeCalls = from aEnumTyp in aEnumTyps select new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), CSchema.RegisterEnumType_Name, new CodeTypeOfExpression(this.ModelInterpreter.GetTypName(aEnumTyp, true)))); var aRegisterDefaultCalculatorCalls = from aTyp in aModel.Typs where aTyp.GetAttributeValue(this.Tok.Mdl_T_A_Nme_Init).Length > 0 select new CodeExpressionStatement( new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), CSchema.NameOf_RegisterDefaultCalculator), new CodeTypeOfExpression(this.CodeDomBuilder.NewCodeTypeRef(aTyp)), new CodeSnippetExpression("()=>" + aTyp.GetAttributeValue(this.Tok.Mdl_T_A_Nme_Init)) ) ); aCtor.Statements.AddRange((from aEnoCls in this.ModelInterpreter.GetEntityObjectTyps(aModel) select this.NewAddPrototypeStatement(aEnoCls)).ToArray()); aCtor.Statements.AddRange(aRegisterEnumTypeCalls.ToArray()); aCtor.Statements.AddRange(aRegisterDefaultCalculatorCalls.ToArray()); aCtor.Statements.Add(new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), CSchema.NameOf_Init)); return(aCtor); }
public virtual string GetClrNamespace(CRflModel aModel) => aModel.GetAttributeValue(string.Empty, string.Empty, this.Tok.Mdl_G_A_Nsp_Nme);
public abstract CRflModel Expand(CRflModel Model);
public CRflModel NewIncludedModel(FileInfo aFileInfo) => CRflModel.NewFromTextFile(this, aFileInfo);
public virtual IEnumerable <CRflTyp> GetEnumTyps(CRflModel aModel) => from aTyp in aModel.Typs where this.GetIsEnum(aTyp) select aTyp;
public virtual IEnumerable <string> GetClrNamespaces(CRflModel aMdl) => (from aTyp in aMdl.Typs where aTyp.Name.Length > 0 select aTyp.GetPropertyAttributeValue(this.Tok.Mdl_T_A_Nme_ClrNs)).Where(aNs => aNs.Length > 0);
public IEnumerable <CInclude> GetIncludes(CRflModel aModel) => from aAttribute in aModel.GetAttributes(string.Empty, string.Empty, this.Tok.Mdl_G_A_Include) select new CInclude(aAttribute.Row, new FileInfo(Path.Combine(aModel.FileInfo.Directory.FullName, aAttribute.Value)));
public override CRflModel Expand(CRflModel aModel) { return(new CRflModel(aModel.ModelInterpreter, aModel.FileInfo, aModel.Rows.Concat(this.Rows))); }
private void LoadInput() => this.Model = this.Exp.Expand(CRflModel.NewFromTextFile(this.ModelInterpreter, this.ModelInputFileInfo));
public virtual string GetSchema(CRflModel aMdl) => aMdl.GetAttributeValue(string.Empty, string.Empty, this.Tok.Mdl_G_A_ModelName);
public override CRflModel Expand(CRflModel Model) => Model;
public override CRflModel Expand(CRflModel Model) { throw new NotImplementedException(); }
public virtual IEnumerable <CRflTyp> GetEntityObjectTyps(CRflModel aMdl) => from aTest in aMdl.Typs where this.GetBase(aTest) == this.Tok.Trg_C_Eno_Nme select aTest;
internal CRflTyp(CRflModel aRflModel, string aName, CRflRow[] aRflRows) { this.Model = aRflModel; this.Name = aName; this.PropertiesDic = (from aGroup in aRflRows.GroupBy(aRflRow => aRflRow.PropertyName) select new CRflProperty(this, aGroup.Key, aGroup.ToArray())).ToDictionary(aForKey => aForKey.Name); }