コード例 #1
0
 /// <summary>
 /// Removes a specific document type from the configuration
 /// </summary>
 /// <param name="documentType"></param>
 public void RemoveDocumentType(RaspDocumentTypeConfig 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(RaspDocumentTypeConfig documentType)
        {
            Predicate <RaspDocumentTypeConfig> match = delegate(RaspDocumentTypeConfig current) {
                return(current.Equals(documentType));
            };

            return(_documentTypes.Exists(match));
        }
コード例 #3
0
        /// <summary>
        /// Get a document type from the id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public RaspDocumentTypeConfig GetDocumentType(Guid id)
        {
            RaspDocumentTypeConfig documentType = null;

            if (!TryGetDocumentType(id, out documentType))
            {
                throw new NoDocumentTypeFoundFromIdException(id);
            }
            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(RaspDocumentTypeConfig documentType)
 {
     if (documentType == null)
     {
         throw new NullArgumentException("documentType");
     }
     if (ContainsDocumentTypeByValue(documentType))
     {
         throw new RaspDocumentAllreadyAddedException(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 RaspDocumentTypeConfig documentType)
        {
            documentType = null;
            Predicate <RaspDocumentTypeConfig> match = delegate(RaspDocumentTypeConfig current) {
                return(id == current.Id);
            };
            List <RaspDocumentTypeConfig> 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 RaspDocumentTypeConfig 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");
            }

            RaspDocumentTypeConfig 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 RaspDocumentTypeConfig 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 <RaspDocumentTypeConfig> match = delegate(RaspDocumentTypeConfig current) {
                if (rootName != current.RootName)
                {
                    return(false);
                }
                if (rootNamespace != current.RootNamespace)
                {
                    return(false);
                }
                return(identifierDiscriminators == current.IdentifierDiscriminators);
            };
            List <RaspDocumentTypeConfig> 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(RaspDocumentTypeConfig documentType)
 {
     return(_documentTypes.Contains(documentType));
 }