///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <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); } }
///<summary>Standard type converter method</summary> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { AtomTextConstruct tc = value as AtomTextConstruct; if (destinationType == typeof(System.String) && tc != null) { return(tc.Type + ": " + tc.Text); } return(base.ConvertTo(context, culture, value, destinationType)); }
////////////////////////////////////////////////////////////////////// /// <summary>parses an AtomTextConstruct</summary> /// <param name="reader">the xmlreader correctly positioned at the construct </param> /// <param name="owner">the container element</param> /// <returns>the new text construct </returns> ////////////////////////////////////////////////////////////////////// protected AtomTextConstruct ParseTextConstruct(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 System.ArgumentNullException("owner"); } //Tracing.TraceCall("Parsing atomTextConstruct"); AtomTextConstruct construct = owner.CreateAtomSubElement(reader, this) as AtomTextConstruct; if (reader.NodeType == XmlNodeType.Element) { if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { object attributeName = reader.LocalName; if (attributeName.Equals(this.nameTable.Type)) { construct.Type = (AtomTextConstructType)Enum.Parse( typeof(AtomTextConstructType), Utilities.DecodedValue(reader.Value), true); } else { ParseBaseAttributes(reader, construct); } } } reader.MoveToElement(); switch (construct.Type) { case AtomTextConstructType.html: case AtomTextConstructType.text: construct.Text = Utilities.DecodedValue(reader.ReadString()); break; case AtomTextConstructType.xhtml: default: construct.Text = reader.ReadInnerXml(); break; } } return(construct); }