Example #1
0
 protected override SyndicationItem CreateItemInstance()
 {
     return(SyndicationItemFormatter.CreateItemInstance(_itemType));
 }
            public void AddEntry(SyndicationItemFormatter item)
            {
                WebOperationContext context = WebOperationContext.Current;

                // Add entry
                // ..

                context.OutgoingResponse.StatusCode = HttpStatusCode.Created;
                context.OutgoingResponse.StatusDescription = String.Format("Syndication item added with title '{0}'", item.Item.Title.Text);
            }
        /// <summary>Reads a SyndicationItem object from the specified XmlReader.</summary>
        /// <param name='formatter'>Formatter to use when reading content.</param>
        /// <param name='reader'>Read to read feed from.</param>
        /// <returns>A new SyndicationItem instance.</returns>
        private static SyndicationItem ReadSyndicationItem(SyndicationItemFormatter formatter, XmlReader reader)
        {
            Debug.Assert(formatter != null, "formatter != null");
            Debug.Assert(reader != null, "reader != null");

            try
            {
                formatter.ReadFrom(reader);
            }
            catch (XmlException exception)
            {
                throw DataServiceException.CreateBadRequestError(Strings.Syndication_ErrorReadingEntry(exception.Message), exception);
            }

            Debug.Assert(formatter.Item != null, "formatter.Item != null");
            return formatter.Item;
        }