private void TestConfiguration(MessageReaderConfiguration _item) { foreach (ConsumerAssociationConfiguration _ax in _item.ConsumerAssociationConfigurations) { AssociationsDictionary.Add(_ax.AssociationName, _ax); } MessageTransportConfigurationDictionary.Add(_item.Name, _item); Assert.IsNull(_item.Configuration); }
public RunTimeMetadata(DbSetsDictionary dbSets, ILookup <Type, DbSetInfo> dbSetsByTypeLookUp, AssociationsDictionary associations, MethodMap svcMethods, OperationalMethods operMethods, string[] typeScriptImports) { DbSets = dbSets; this.dbSetsByTypeLookUp = dbSetsByTypeLookUp; Associations = associations; _svcMethods = svcMethods; _operMethods = operMethods; TypeScriptImports = typeScriptImports; }
public RunTimeMetadata Build() { DbSetsDictionary dbSets = new DbSetsDictionary(); foreach (DbSetInfo dbSetInfo in designTimeMetadata.DbSets) { dbSets.Add(dbSetInfo.dbSetName, dbSetInfo); } foreach (DbSetInfo dbSetInfo in dbSets.Values) { dbSetInfo.Initialize(dataHelper); } ILookup <Type, DbSetInfo> dbSetsByTypeLookUp = dbSets.Values.ToLookup(v => v.GetEntityType()); MethodMap svcMethods = new MethodMap(); OperationalMethods operMethods = new OperationalMethods(); foreach (Config.ServiceTypeDescriptor descriptor in dataManagerContainer.Descriptors) { ProcessMethodDescriptions(descriptor.ImplementationType, svcMethods, operMethods, dbSets, dbSetsByTypeLookUp); } ProcessMethodDescriptions(domainServiceType, svcMethods, operMethods, dbSets, dbSetsByTypeLookUp); operMethods.MakeReadOnly(); svcMethods.MakeReadOnly(); AssociationsDictionary associations = new AssociationsDictionary(); foreach (Association assoc in designTimeMetadata.Associations) { ProcessAssociation(assoc, dbSets, associations); } return(new RunTimeMetadata(dbSets, dbSetsByTypeLookUp, associations, svcMethods, operMethods, designTimeMetadata.TypeScriptImports.ToArray())); }
private void ProcessAssociation(Association assoc, DbSetsDictionary dbSets, AssociationsDictionary associations) { if (string.IsNullOrWhiteSpace(assoc.name)) { throw new DomainServiceException(ErrorStrings.ERR_ASSOC_EMPTY_NAME); } if (!dbSets.ContainsKey(assoc.parentDbSetName)) { throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_PARENT, assoc.name, assoc.parentDbSetName)); } if (!dbSets.ContainsKey(assoc.childDbSetName)) { throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_CHILD, assoc.name, assoc.childDbSetName)); } DbSetInfo childDb = dbSets[assoc.childDbSetName]; DbSetInfo parentDb = dbSets[assoc.parentDbSetName]; Dictionary <string, Field> parentDbFields = parentDb.GetFieldByNames(); Dictionary <string, Field> childDbFields = childDb.GetFieldByNames(); //check navigation field //dont allow to define it explicitly, the association adds the field by itself (implicitly) if (!string.IsNullOrEmpty(assoc.childToParentName) && childDbFields.ContainsKey(assoc.childToParentName)) { throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_NAV_FIELD, assoc.name, assoc.childToParentName)); } //check navigation field //dont allow to define it explicitly, the association adds the field by itself (implicitly) if (!string.IsNullOrEmpty(assoc.parentToChildrenName) && parentDbFields.ContainsKey(assoc.parentToChildrenName)) { throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_NAV_FIELD, assoc.name, assoc.parentToChildrenName)); } if (!string.IsNullOrEmpty(assoc.parentToChildrenName) && !string.IsNullOrEmpty(assoc.childToParentName) && assoc.childToParentName == assoc.parentToChildrenName) { throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_NAV_FIELD, assoc.name, assoc.parentToChildrenName)); } foreach (FieldRel frel in assoc.fieldRels) { if (!parentDbFields.ContainsKey(frel.parentField)) { throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_PARENT_FIELD, assoc.name, frel.parentField)); } if (!childDbFields.ContainsKey(frel.childField)) { throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_CHILD_FIELD, assoc.name, frel.childField)); } } //indexed by Name associations.Add(assoc.name, assoc); if (!string.IsNullOrEmpty(assoc.childToParentName)) { StringBuilder sb = new StringBuilder(120); string dependentOn = assoc.fieldRels.Aggregate(sb, (a, b) => a.Append((a.Length == 0 ? "" : ",") + b.childField), a => a).ToString(); //add navigation field to dbSet's field collection Field fld = new Field { fieldName = assoc.childToParentName, fieldType = FieldType.Navigation, dataType = DataType.None, dependentOn = dependentOn }; fld.SetTypeScriptDataType(TypeScriptHelper.GetEntityInterfaceName(parentDb.dbSetName)); childDb.fieldInfos.Add(fld); } if (!string.IsNullOrEmpty(assoc.parentToChildrenName)) { StringBuilder sb = new StringBuilder(120); Field fld = new Field { fieldName = assoc.parentToChildrenName, fieldType = FieldType.Navigation, dataType = DataType.None }; fld.SetTypeScriptDataType($"{TypeScriptHelper.GetEntityInterfaceName(childDb.dbSetName)}[]"); //add navigation field to dbSet's field collection parentDb.fieldInfos.Add(fld); } }