Beispiel #1
0
        /// <exception cref="InvalidOperationException" />
        /// <exception cref="NotSupportedException" />
        private ArticleObject ConvertArticle(Article article, ArticleContext context, bool forExtension = false)
        {
            if (!context.ShouldIncludeArticle(article))
            {
                return(null);
            }

            var dict = new ArticleObject
            {
                [ArticleObject._ServerId] = article.Id,
            };

            if (forExtension)
            {
                dict[ArticleObject._IsExtension] = true;
            }
            else if (context.Visited.Contains(article))
            {
                return(dict);
            }
            else
            {
                context.Visited.Add(article);
            }

            if (!article.IsReadOnly)
            {
                dict[ArticleObject._Modified] = article.Modified == default(DateTime)
                    ? article.Created
                    : article.Modified;
            }

            foreach (ArticleField field in article)
            {
                if (context.ShouldIncludeField(field))
                {
                    PopulateField(dict, field, context);
                }
            }

            return(dict);
        }