コード例 #1
0
 /// <summary>
 /// Add a context document to the context documentation.
 /// </summary>
 /// <param name="contextDocument">Context document.</param>
 public virtual void AddContextDocument(IContextDocument contextDocument)
 {
     if (contextDocument == null)
     {
         throw new ArgumentNullException("contextDocument");
     }
     _contextDocuments.Add(contextDocument);
 }
コード例 #2
0
        private void AddContextDocument(IContextDocument contextDocument)
        {
            if (contextDocument == null)
            {
                throw new ArgumentNullException("contextDocument");
            }

            var doc = AddElement(Root, "document");

            AddElement(doc, "documentID", contextDocument.Id.ToString(CultureInfo.InvariantCulture));
            AddElement(doc, "documentTitle", contextDocument.NameTarget);
            AddElement(doc, "documentDescription", contextDocument.Description, true);
            if (contextDocument.DocumentDate.HasValue)
            {
                var documentDate = contextDocument.DocumentDate.Value;

                string dateValue;
                switch (contextDocument.DocumentDatePresicion)
                {
                case DateTimePresicion.Year:
                    dateValue = documentDate.ToString("yyyy");
                    break;

                case DateTimePresicion.Month:
                    dateValue = documentDate.ToString("yyyy-MM");
                    break;

                case DateTimePresicion.Day:
                    dateValue = documentDate.ToString("yyyy-MM-dd");
                    break;

                default:
                    throw new DeliveryEngineRepositoryException(Resource.GetExceptionMessage(ExceptionMessage.IllegalValue, "DocumentDatePresicion", contextDocument.DocumentDatePresicion));
                }

                AddElement(doc, "documentDate", dateValue);
            }

            foreach (var documentAuthor in contextDocument.DocumentAuthors)
            {
                var documentAuthorElement = AddElement(doc, "documentAuthor");

                if (documentAuthor.Author != null)
                {
                    AddElement(documentAuthorElement, "authorName", documentAuthor.Author);
                }

                if (documentAuthor.Institution != null)
                {
                    AddElement(documentAuthorElement, "authorInstitution", documentAuthor.Institution);
                }
            }

            var documentCategory = AddElement(doc, "documentCategory");

            AddCategories(documentCategory, contextDocument.Categories);
        }