コード例 #1
0
ファイル: FeedSourceManager.cs プロジェクト: romesc/RssBandit
        /// <summary>
        /// Adds the specified new source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">If source or name are null</exception>
        /// <exception cref="ArgumentOutOfRangeException">If name is empty</exception>
        /// <exception cref="InvalidOperationException">If source with provided name yet exists</exception>
        public FeedSourceEntry Add(FeedSource source, string name)
        {
            source.ExceptionIfNull("source");
            name.ExceptionIfNullOrEmpty("name");

            if (Contains(name))
            {
                throw new InvalidOperationException("Entry with name '" + name + "' already exists");
            }

            source.sourceID = UniqueKey;
            FeedSourceEntry fs = new FeedSourceEntry(source.sourceID, source, name, _feedSources.Count);

            _feedSources.Add(fs.ID, fs);
            return(fs);
        }