/// <summary> /// Apply projection for the given property to the parent projection node. /// </summary> /// <param name="parentNode">The parent node which the new node will be added to.</param> /// <param name="propertyName">Name of the property that needs to be projected.</param> /// <param name="property">ResourceProperty instance containing information about the property - this will be null for open properties.</param> /// <param name="targetResourceType">ResourceType instance on which the property needs to be expanded.</param> /// <returns>A new or an existing instance of the ExpandedProjectionNode for the given property.</returns> private static ExpandedProjectionNode ApplyProjectionForProperty(ExpandedProjectionNode parentNode, string propertyName, ResourceProperty property, ResourceType targetResourceType) { Debug.Assert(parentNode != null, "parentNode != null"); Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)"); Debug.Assert(targetResourceType != null, "targetResourceType != null"); var childNode = parentNode.AddProjectionNode(propertyName, property, targetResourceType); Debug.Assert( childNode == null || childNode.ResourceType == property.ResourceType, "If we're traversing over a nav. property it's resource type must match the resource type of the expanded segment."); return childNode; }