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); }
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); } }