/// <summary> /// Parses the content on the reader into the specified <paramref name="targetEntry"/>. /// </summary> /// <param name="targetEntry">Target to read values into.</param> private void ParseCurrentContent(AtomEntry targetEntry) { Debug.Assert(targetEntry != null, "targetEntry != null"); Debug.Assert(this.reader.NodeType == XmlNodeType.Element, "this.reader.NodeType == XmlNodeType.Element"); string propertyValue = this.reader.GetAttributeEx(XmlConstants.AtomContentSrcAttributeName, XmlConstants.AtomNamespace); if (propertyValue != null) { // This is a media link entry // Note that in this case we don't actually use this URL (or the link/edit-media URL) // for editing. We rely on the Astoria URL convention (/propname/$value or just /$value) if (!this.reader.IsEmptyElement) { throw Error.InvalidOperation(Strings.Deserialize_ExpectedEmptyMediaLinkEntryContent); } targetEntry.MediaLinkEntry = true; targetEntry.MediaContentUri = new Uri(propertyValue, UriKind.RelativeOrAbsolute); } else { // This is a regular (non-media link) entry if (targetEntry.MediaLinkEntry.HasValue && targetEntry.MediaLinkEntry.Value) { // This means we saw a <m:Properties> element but now we have a Content element // that's not just a media link entry pointer (src) throw Error.InvalidOperation(Strings.Deserialize_ContentPlusPropertiesNotAllowed); } targetEntry.MediaLinkEntry = false; propertyValue = this.reader.GetAttributeEx(XmlConstants.AtomTypeAttributeName, XmlConstants.AtomNamespace); if (AtomParser.IsAllowedContentType(propertyValue)) { if (this.reader.IsEmptyElement) { return; } if (ReadChildElement(this.reader, XmlConstants.AtomPropertiesElementName, XmlConstants.DataWebMetadataNamespace)) { this.ReadCurrentProperties(targetEntry.DataValues); } else if (this.reader.NodeType != XmlNodeType.EndElement) { throw Error.InvalidOperation(Strings.Deserialize_NotApplicationXml); } } } }
private void ParseCurrentContent(AtomEntry targetEntry) { Debug.Assert(targetEntry != null, "targetEntry != null"); Debug.Assert(this.reader.NodeType == XmlNodeType.Element, "this.reader.NodeType == XmlNodeType.Element"); string propertyValue = this.reader.GetAttributeEx(XmlConstants.AtomContentSrcAttributeName, XmlConstants.AtomNamespace); if (propertyValue != null) { if (!this.reader.IsEmptyElement) { throw Error.InvalidOperation(Strings.Deserialize_ExpectedEmptyMediaLinkEntryContent); } targetEntry.MediaLinkEntry = true; targetEntry.MediaContentUri = new Uri(propertyValue, UriKind.RelativeOrAbsolute); } else { if (targetEntry.MediaLinkEntry.HasValue && targetEntry.MediaLinkEntry.Value) { throw Error.InvalidOperation(Strings.Deserialize_ContentPlusPropertiesNotAllowed); } targetEntry.MediaLinkEntry = false; propertyValue = this.reader.GetAttributeEx(XmlConstants.AtomTypeAttributeName, XmlConstants.AtomNamespace); if (AtomParser.IsAllowedContentType(propertyValue)) { if (this.reader.IsEmptyElement) { return; } if (ReadChildElement(this.reader, XmlConstants.AtomPropertiesElementName, XmlConstants.DataWebMetadataNamespace)) { this.ReadCurrentProperties(targetEntry.DataValues); } else if (this.reader.NodeType != XmlNodeType.EndElement) { throw Error.InvalidOperation(Strings.Deserialize_NotApplicationXml); } } } }