Пример #1
0
        public virtual IGraph <TItem, TEdge> CreateSinkGraph(IGraph <TItem, TEdge> source)
        {
            IGraphPair <TItem, TItem, TEdge, TEdge> sourceGraph = source as SubGraph <TItem, TEdge>;

            if (sourceGraph != null)
            {
                sourceGraph = sourceGraph.RootSource();

                var backHandler = BackHandler(sourceGraph);

                if (backHandler != null)
                {
                    var result = backHandler.CreateSinkGraph(sourceGraph.Source);

                    if (result != null)
                    {
                        // souround with a view
                        var view = Activator.CreateInstance((result as ISinkGraph <TItem, TEdge>).Sink.GetType())
                                   as IGraph <TItem, TEdge>;
                        return(new SubGraph <TItem, TEdge> (result, view));
                    }
                }
                else
                {
                    // asuming a graph without backing graph
                    var view = Activator.CreateInstance(sourceGraph.Source.GetType()) as IGraph <TItem, TEdge>;
                    return(new SubGraph <TItem, TEdge> (sourceGraph.Source, view));
                }
            }
            return(null);
        }
Пример #2
0
        LookUp <TItem, TEdge, TSourceItem, TSourceEdge> (
            this IGraphPair <TItem, TItem, TEdge, TEdge> graphPair1,
            IGraphPair <TItem, TItem, TEdge, TEdge> graphPair2,
            TItem item) where TEdge : IEdge <TItem>, TItem
            where TSourceEdge : IEdge <TSourceItem>, TSourceItem
        {
            var back    = default(TItem);
            var source1 = graphPair1.Source <TItem, TEdge, TSourceItem, TSourceEdge>();
            var source2 = graphPair2.Source <TItem, TEdge, TSourceItem, TSourceEdge>();

            if (source1 != null && source2 != null)
            {
                var ping = source1.Get(item);
                if (ping != null)
                {
                    var contains = ping is TSourceEdge?source2.Source.Contains((TSourceEdge)ping) : source2.Source.Contains(ping);

                    if (contains)
                    {
                        back = source2.Get(ping);
                    }
                }
            }
            return(back);
        }
Пример #3
0
        public override void ChangeData(IGraph <IGraphEntity, IGraphEdge> sink, IGraphEntity item, object data)
        {
            IGraphPair <IGraphEntity, IThing, IGraphEdge, ILink> graph =
                sink as IGraphPair <IGraphEntity, IThing, IGraphEdge, ILink>;

            if (graph != null)
            {
                var thing = graph.Get(item);
                thing.Data = data;
                item.Data  = data;
            }
        }
Пример #4
0
 public EdgeList(IGraphPair <TSinkItem, TSourceItem, TSinkEdge, TSourceEdge> graphPair, IList <TSourceEdge> listTwo)
 {
     this.graphPair = graphPair;
     this.listTwo   = listTwo;
 }