/// <summary> /// Removes a specific document type from the configuration /// </summary> /// <param name="documentType"></param> public void RemoveDocumentType(DocumentTypeConfig documentType) { if (documentType == null) { throw new NullArgumentException("documentType"); } _documentTypes.Remove(documentType); }
/// <summary> /// Returns whether a certain document type is in the collection. The document type is in /// the collection if it has the same id or has the same root name, root namespace and /// identifier discriminators. /// </summary> /// <param name="documentType"></param> /// <returns></returns> public bool ContainsDocumentTypeByValue(DocumentTypeConfig documentType) { Predicate <DocumentTypeConfig> match = delegate(DocumentTypeConfig current) { return(current.Equals(documentType)); }; return(_documentTypes.Exists(match)); }
/// <summary> /// Get a document type from the id /// </summary> /// <param name="guid"></param> /// <returns></returns> public DocumentTypeConfig GetDocumentType(Guid guid) { DocumentTypeConfig documentType = null; if (!TryGetDocumentType(guid, out documentType)) { throw new NoDocumentTypeFoundFromIdException(guid); } return(documentType); }
/// <summary> /// Adds a new RASP document type to the configuration /// </summary> /// <param name="documentType">documenttype to add</param> public void AddDocumentType(DocumentTypeConfig documentType) { if (documentType == null) { throw new NullArgumentException("documentType"); } if (ContainsDocumentTypeByValue(documentType)) { throw new DocumentAllreadyAddedException(documentType.FriendlyName); } _documentTypes.Add(documentType); }
/// <summary> /// Try to get the document type with a certain id /// </summary> /// <param name="id"></param> /// <param name="documentType"></param> /// <returns></returns> public bool TryGetDocumentType(Guid id, out DocumentTypeConfig documentType) { documentType = null; Predicate <DocumentTypeConfig> match = delegate(DocumentTypeConfig current) { return(id == current.Id); }; List <DocumentTypeConfig> documentTypes = _documentTypes.FindAll(match); if (documentTypes.Count < 1) { return(false); } if (documentTypes.Count > 1) { throw new AmbiguousDocumentTypeResultFromIdException(id); } documentType = documentTypes[0]; return(true); }
/// <summary> /// Get a 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> /// <returns></returns> public DocumentTypeConfig GetDocumentType(string rootName, string rootNamespace, XpathDiscriminatorConfigCollection identifierDiscriminators) { if (rootName == null) { throw new ArgumentNullException("rootName"); } if (rootNamespace == null) { throw new ArgumentNullException("rootNamespace"); } if (identifierDiscriminators == null) { throw new ArgumentNullException("identifierDiscriminators"); } DocumentTypeConfig documentType = null; if (!TryGetDocumentType(rootName, rootNamespace, identifierDiscriminators, out documentType)) { throw new NoDocumentTypeFoundFromParametersException(rootName, rootNamespace, identifierDiscriminators); } return(documentType); }
/// <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); }
/// <summary> /// Returns whether a certain document type is in the collection. The document type is in /// the collectio if the reference is the same. /// </summary> /// <param name="documentType"></param> /// <returns></returns> public bool ContainsDocumentTypeByReference(DocumentTypeConfig documentType) { return(_documentTypes.Contains(documentType)); }