/// <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"); } _title = updatedEntry.Title; _authors = updatedEntry.Authors; _id = updatedEntry.Id; _links = updatedEntry.Links; _lastUpdateDate = updatedEntry.Updated; _publicationDate = updatedEntry.Published; _authors = updatedEntry.Authors; _rights = updatedEntry.Rights; _categories = updatedEntry.Categories; _summary = updatedEntry.Summary; _content = updatedEntry.Content; _source = updatedEntry.Source; ExtensionElements.Clear(); foreach (IExtensionElementFactory extension in updatedEntry.ExtensionElements) { ExtensionElements.Add(extension); } }
///<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)); }
/// <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(_nameTable.Type)) { content.Type = Utilities.DecodedValue(reader.Value); } else if (localname.Equals(_nameTable.Src)) { content.Src = new AtomUri(reader.Value); } else { ParseBaseAttributes(reader, content); } } } if (MoveToStartElement(reader)) { 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) { // 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); }