コード例 #1
0
 /// <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);
 }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
 /// <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);
 }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
 /// <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));
 }