示例#1
0
 protected SyndicationItem(SyndicationItem source)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     _extensions      = source._extensions.Clone();
     _authors         = FeedUtils.ClonePersons(source._authors);
     _categories      = FeedUtils.CloneCategories(source._categories);
     _content         = (source._content != null) ? source._content.Clone() : null;
     _contributors    = FeedUtils.ClonePersons(source._contributors);
     _copyright       = FeedUtils.CloneTextContent(source._copyright);
     _id              = source._id;
     _lastUpdatedTime = source._lastUpdatedTime;
     _links           = FeedUtils.CloneLinks(source._links);
     _publishDate     = source._publishDate;
     if (source.SourceFeed != null)
     {
         _sourceFeed       = source._sourceFeed.Clone(false);
         _sourceFeed.Items = new Collection <SyndicationItem>();
     }
     _summary = FeedUtils.CloneTextContent(source._summary);
     _baseUri = source._baseUri;
     _title   = FeedUtils.CloneTextContent(source._title);
 }
示例#2
0
        protected SyndicationFeed(SyndicationFeed source, bool cloneItems)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            _authors         = FeedUtils.ClonePersons(source._authors);
            _categories      = FeedUtils.CloneCategories(source._categories);
            _contributors    = FeedUtils.ClonePersons(source._contributors);
            _copyright       = FeedUtils.CloneTextContent(source._copyright);
            _description     = FeedUtils.CloneTextContent(source._description);
            _extensions      = source._extensions.Clone();
            _generator       = source._generator;
            _id              = source._id;
            _imageUrl        = source._imageUrl;
            _language        = source._language;
            _lastUpdatedTime = source._lastUpdatedTime;
            _links           = FeedUtils.CloneLinks(source._links);
            _title           = FeedUtils.CloneTextContent(source._title);
            _baseUri         = source._baseUri;
            IList <SyndicationItem> srcList = source._items as IList <SyndicationItem>;

            if (srcList != null)
            {
                Collection <SyndicationItem> tmp = new NullNotAllowedCollection <SyndicationItem>();
                for (int i = 0; i < srcList.Count; ++i)
                {
                    tmp.Add((cloneItems) ? srcList[i].Clone() : srcList[i]);
                }
                _items = tmp;
            }
            else
            {
                if (cloneItems)
                {
                    throw new InvalidOperationException(SR.UnbufferedItemsCannotBeCloned);
                }
                _items = source._items;
            }
        }