public void VisitResourceNavigationProperty(ResourceInstanceNavProperty navProperty, XmlElement parentNode) { if (navProperty is ResourceInstanceNavColProperty) { VisitResourceNavigationCollectionProperty(navProperty as ResourceInstanceNavColProperty, parentNode); } else { VisitResourceNavigationRefProperty(navProperty as ResourceInstanceNavRefProperty, parentNode); } }
private XmlElement CreateAtomLinkElement(ResourceInstanceNavProperty navProperty, XmlElement parentNode, string hrefValue) { XmlElement linkNode = CreateAtomElement("link"); XmlAttribute relAttribute = CreateAtomAttribute("rel"); relAttribute.Value = DataWebRelatedXmlNamespace + navProperty.Name; linkNode.Attributes.Append(relAttribute); /* * XmlAttribute titleAttribute = CreateAtomAttribute("title"); * titleAttribute.Value = navProperty.Name; * linkNode.Attributes.Append(titleAttribute); */ if (hrefValue != null) { XmlAttribute hrefAttribute = CreateAtomAttribute("href"); hrefAttribute.Value = hrefValue; linkNode.Attributes.Append(hrefAttribute); } return(linkNode); }
public void VisitResourceNavigationRefProperty(ResourceInstanceNavProperty navProperty, ResourceBodyTree treeNode, XmlElement parentNode) { string type = ""; string hrefKey = null; XmlElement inlineElement = null; if (treeNode is AssociationResourceInstance) { AssociationResourceInstance instance = treeNode as AssociationResourceInstance; hrefKey = CreateCanonicalUri(instance.ResourceInstanceKey).Replace(Workspace.ServiceUri + @"\", ""); } else { inlineElement = CreateDataWebMetadataElement("inline"); if (navProperty is ResourceInstanceNavColProperty) { XmlElement feedNode = CreateAtomElement("feed"); this.Visit(navProperty, treeNode, feedNode); inlineElement.AppendChild(feedNode); type = "feed"; } else { this.Visit(navProperty, treeNode, inlineElement); type = "entry"; } } XmlElement linkElement = CreateAtomLinkElement(navProperty, parentNode, hrefKey); XmlAttribute typeAttribute = CreateAtomAttribute("type"); typeAttribute.Value = "application/atom+xml;type=" + type; linkElement.Attributes.Append(typeAttribute); if (inlineElement != null) { linkElement.AppendChild(inlineElement); } parentNode.AppendChild(linkElement); }
private void CreateEntryElement(KeyedResourceInstance keyedResourceInstance, XmlNode parentNode) { currentResource = keyedResourceInstance; XmlElement entryElement = CreateBasicEntryElement(keyedResourceInstance, parentNode); //string relativeParentKey = null; //Add the Id if there is one if (this.RequestVerb != RequestVerb.Post) { if (keyedResourceInstance.ResourceInstanceKey != null) { XmlElement idNode = CreateIdElement(keyedResourceInstance); entryElement.AppendChild(idNode); } } ResourceType type = Workspace.ServiceContainer.ResourceTypes.Single(rt => rt.Name == keyedResourceInstance.TypeName); XmlElement propertiesNode = CreateDataWebMetadataElement("properties"); IEnumerable <ResourceInstanceProperty> properties = keyedResourceInstance.Properties; if (this.RequestVerb == RequestVerb.Post && keyedResourceInstance.ResourceInstanceKey != null) { properties = keyedResourceInstance.ResourceInstanceKey.KeyProperties.Union(properties); } foreach (ResourceInstanceProperty property in properties) { if (property is ResourceInstanceSimpleProperty) { ResourceInstanceSimpleProperty simpleResourceProperty = property as ResourceInstanceSimpleProperty; VisitResourceInstanceSimpleProperty(simpleResourceProperty, propertiesNode); } else if (property is ResourceInstanceComplexProperty) { ResourceInstanceComplexProperty complexResourceProperty = property as ResourceInstanceComplexProperty; if (complexResourceProperty.ComplexResourceInstance == null) { VisitResourceInstanceComplexProperty(complexResourceProperty, propertiesNode); } else { VisitResourceInstanceComplexProperty(complexResourceProperty, propertiesNode); } } else if (property is ResourceInstanceNavProperty) { ResourceInstanceNavProperty navigationProperty = property as ResourceInstanceNavProperty; VisitResourceNavigationProperty(navigationProperty, entryElement); } } if (propertiesNode.ChildNodes.Count > 0) { if (!type.Facets.HasStream) { XmlElement contentNode = CreateAtomElement("content"); XmlAttribute contentTypeAttribute = CreateAtomAttribute("type"); contentTypeAttribute.Value = RequestUtil.RandomizeContentTypeCapitalization("application/xml"); contentNode.Attributes.Append(contentTypeAttribute); contentNode.AppendChild(propertiesNode); entryElement.AppendChild(contentNode); } else { entryElement.AppendChild(propertiesNode); } } if (EntryElementCallback != null) { EntryElementCallback(entryElement); } }