/// <summary> /// Return whether the given document type config is equal to another. /// They are equal if they have the same id or if they have the same /// root name, root namespace and identifier discriminators. /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(RaspDocumentTypeConfig other) { if (_id == other._id) { return(true); } if (_rootName != other._rootName) { return(false); } if (_rootNamespace != other._rootNamespace) { return(false); } return(_identifierDiscriminators.Equals(other._identifierDiscriminators)); }
/// <summary> /// Try to get the document type from a root name, root namespace and a collection of /// identifier expressions. /// </summary> /// <param name="rootName"></param> /// <param name="rootNamespace"></param> /// <param name="identifierDiscriminators"></param> /// <param name="documentType"></param> /// <returns></returns> public bool TryGetDocumentType(string rootName, string rootNamespace, XpathDiscriminatorConfigCollection identifierDiscriminators, out DocumentTypeConfig documentType) { if (rootName == null) { throw new ArgumentNullException("rootName"); } if (rootNamespace == null) { throw new ArgumentNullException("rootNamespace"); } if (identifierDiscriminators == null) { throw new ArgumentNullException("identifierDiscriminators"); } documentType = null; Predicate <DocumentTypeConfig> match = delegate(DocumentTypeConfig current) { if (rootName != current.RootName) { return(false); } if (rootNamespace != current.RootNamespace) { return(false); } return(identifierDiscriminators.Equals(current.IdentifierDiscriminators)); }; List <DocumentTypeConfig> documentTypes = _documentTypes.FindAll(match); if (documentTypes.Count < 1) { return(false); } if (documentTypes.Count > 1) { throw new AmbiguousDocumentTypeResultFromParametersException(rootName, rootNamespace, identifierDiscriminators); } documentType = documentTypes[0]; return(true); }