Example #1
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>takes the updated entry returned and sets the properties to this object</summary>
        /// <param name="updatedEntry"> </param>
        //////////////////////////////////////////////////////////////////////
        protected void CopyEntry(AtomEntry updatedEntry)
        {
            //Tracing.Assert(updatedEntry != null, "updatedEntry should not be null");
            if (updatedEntry == null)
            {
                throw new ArgumentNullException("updatedEntry");
            }

            this.title           = updatedEntry.Title;
            this.authors         = updatedEntry.Authors;
            this.id              = updatedEntry.Id;
            this.links           = updatedEntry.Links;
            this.lastUpdateDate  = updatedEntry.Updated;
            this.publicationDate = updatedEntry.Published;
            this.authors         = updatedEntry.Authors;
            this.rights          = updatedEntry.Rights;
            this.categories      = updatedEntry.Categories;
            this.summary         = updatedEntry.Summary;
            this.content         = updatedEntry.Content;
            this.source          = updatedEntry.Source;

            this.ExtensionElements.Clear();

            foreach (IExtensionElementFactory extension in updatedEntry.ExtensionElements)
            {
                this.ExtensionElements.Add(extension);
            }
        }
Example #2
0
        ///<summary>Standard type converter method</summary>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType)
        {
            AtomContent content = value as AtomContent;

            if (destinationType == typeof(System.String) && content != null)
            {
                return("Content-type: " + content.Type);
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
Example #3
0
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>creates an AtomContent object by parsing an xml stream</summary>
        /// <param name="reader">a XMLReader positioned correctly </param>
        /// <param name="owner">the container element</param>
        /// <returns> null or an AtomContent object</returns>
        //////////////////////////////////////////////////////////////////////
        protected AtomContent ParseContent(XmlReader reader, AtomBase owner)
        {
            //Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }


            AtomContent content = owner.CreateAtomSubElement(reader, this) as AtomContent;

            //Tracing.TraceCall();
            if (content != null)
            {
                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        object localname = reader.LocalName;
                        if (localname.Equals(this.nameTable.Type))
                        {
                            content.Type = Utilities.DecodedValue(reader.Value);
                        }
                        else if (localname.Equals(this.nameTable.Src))
                        {
                            content.Src = new AtomUri(reader.Value);
                        }
                        else
                        {
                            ParseBaseAttributes(reader, content);
                        }
                    }
                }

                if (MoveToStartElement(reader) == true)
                {
                    if (content.Type.Equals("text") ||
                        content.Type.Equals("html") ||
                        content.Type.StartsWith("text/"))
                    {
                        // if it's text it get's just the string treatment. No
                        // subelements are allowed here
                        content.Content = Utilities.DecodedValue(reader.ReadString());
                    }
                    else if (content.Type.Equals("xhtml") ||
                             content.Type.Contains("/xml") ||
                             content.Type.Contains("+xml"))
                    {
                        // do not get childlists if the element is empty. That would skip to the next element
                        if (reader.IsEmptyElement == false)
                        {
                            // everything else will be nodes in the extension element list
                            // different media type. Create extension elements
                            int lvl = -1;
                            while (NextChildElement(reader, ref lvl))
                            {
                                ParseExtensionElements(reader, content);
                            }
                        }
                    }
                    else
                    {
                        // everything else SHOULD be base 64 encoded, so one big string
                        // i know the if statement could be combined with the text handling
                        // but i consider it clearer to make a 3 cases statement than combine them
                        content.Content = Utilities.DecodedValue(reader.ReadString());
                    }
                }
            }
            return(content);
        }