예제 #1
0
 private IEnumerable <string> GetObjectLink(IStoreGraph graph, string source, string segment)
 {
     if (string.Compare(segment, Constants.AnyPath, StringComparison.Ordinal) == 0)
     {
         return(graph.O(source).Select(x => x.Subject));
     }
     else
     {
         return(graph.PO(segment, source).Select(x => x.Subject));
     }
 }
예제 #2
0
        private IEnumerable <string> GetByLevel(IStoreGraph graph, IEnumerable <string> sources, int level, bool isOutgoing)
        {
            if (level == 0)
            {
                return(Enumerable.Empty <string>());
            }
            IEnumerable <string> next = new List <string>();

            foreach (var source in sources)
            {
                var items = isOutgoing
                    ? graph.S(source).Where(x => x.Object.IsID).Select(y => y.Object.Id).Distinct()
                    : graph.O(source).Select(y => y.Subject).Distinct();
                var targets = GetByLevel(graph, items, level - 1, isOutgoing);
                next = next.Concat(targets);
            }
            return(sources.Concat(next).Distinct());
        }