Пример #1
0
        private static IReadOnlyCollection <IncludeElementExpression> ConvertChainsToElements(IReadOnlyCollection <ResourceFieldChainExpression> chains)
        {
            var rootNode = new MutableIncludeNode(null);

            foreach (ResourceFieldChainExpression chain in chains)
            {
                ConvertChainToElement(chain, rootNode);
            }

            return(rootNode.Children.Values.Select(child => child.ToExpression()).ToArray());
        }
Пример #2
0
        private static void ConvertChainToElement(ResourceFieldChainExpression chain, MutableIncludeNode rootNode)
        {
            MutableIncludeNode currentNode = rootNode;

            foreach (var relationship in chain.Fields.OfType <RelationshipAttribute>())
            {
                if (!currentNode.Children.ContainsKey(relationship))
                {
                    currentNode.Children[relationship] = new MutableIncludeNode(relationship);
                }

                currentNode = currentNode.Children[relationship];
            }
        }
        private static IReadOnlyCollection <IncludeElementExpression> ConvertChainsToElements(IReadOnlyCollection <ResourceFieldChainExpression> chains)
        {
            var rootNode = new MutableIncludeNode(null);

            foreach (ResourceFieldChainExpression chain in chains)
            {
                MutableIncludeNode currentNode = rootNode;

                foreach (var relationship in chain.Fields.OfType <RelationshipAttribute>())
                {
                    if (!currentNode.Children.ContainsKey(relationship))
                    {
                        currentNode.Children[relationship] = new MutableIncludeNode(relationship);
                    }

                    currentNode = currentNode.Children[relationship];
                }
            }

            return(rootNode.Children.Values.Select(child => child.ToExpression()).ToArray());
        }