예제 #1
0
        /// <summary>
        /// Gets All nodes connected to source node
        /// </summary>
        /// <param name="node">Source node</param>
        /// <returns>Nodes connected source node</returns>
        public IEnumerable <INode> Get(INode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            var linksForNode     = linkRepository.Get(node);
            var equalityComparer = new BaseNodeEqualityComparator();

            return(linksForNode
                   .Flatten()
                   .RemoveNode(node)
                   .Distinct(equalityComparer)
                   .GroupBy(g => g.NodeType)
                   .SelectMany(GetNodesFromRepository));
        }
예제 #2
0
        /// <summary>
        /// Gets All nodes of selected INodeType connected to source node
        /// </summary>
        /// <param name="node">Source node</param>
        /// <param name="nodeType">Node type to filter nodes on</param>
        /// <returns>Nodes connected source node</returns>
        public IEnumerable <T> Get <T>(INode node, INodeType <T> nodeType) where T : INode
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }
            if (nodeType == null)
            {
                throw new ArgumentNullException(nameof(nodeType));
            }
            var linksForNode     = linkRepository.Get(node);
            var equalityComparer = new BaseNodeEqualityComparator();

            var requiredIds = linksForNode
                              .Flatten()
                              .Where(n => n.NodeType.Equals(nodeType))
                              .Distinct(equalityComparer)
                              .Select(n => n.Id);
            var repo = repositoryFactory.CreateRepository(nodeType);

            return(repo.Get(requiredIds));
        }