コード例 #1
0
        /// <summary>
        /// Add the projection node with the given property name, property instance and target resource type, if required.
        /// </summary>
        /// <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 ProjectionNode.</returns>
        internal ExpandedProjectionNode AddProjectionNode(string propertyName, ResourceProperty property, ResourceType targetResourceType)
        {
            // find out if there exists another node with the given property name.
            ProjectionNode node = this.FindNode(propertyName);

            if (node == null || !ExpandedProjectionNode.ApplyPropertyToExistingNode(node, property, targetResourceType))
            {
                // just create a simple projection node for it
                node = new ProjectionNode(propertyName, property, targetResourceType);
                this.AddNode(node);
            }

            return(node as ExpandedProjectionNode);
        }