public static IThingGraph BackGraph(this IGraphSceneMesh <IVisual, IVisualEdge> mesh, Iori iori) { IThingGraph thingGraph = null; var backHandler = mesh.BackHandler <IThing, ILink> (); Func <IThingGraph, IThingGraph> register = s => { if (s == null) { return(null); } var g = backHandler.WrapGraph(s) as IThingGraph; backHandler.RegisterBackGraph(g); return(g); }; if (iori != null) { thingGraph = backHandler .BackGraphs .Select(g => new { Iori = GetIori(g), Graph = g }) .Where(i => i.Iori != null && i.Iori.ToString() == iori.ToString()) .Select(i => i.Graph as IThingGraph) .FirstOrDefault(); if (thingGraph == null) { thingGraph = register(ThingMeshHelper.OpenGraph(iori)); } } if (thingGraph == null && iori == null) { Trace.WriteLine("Warning! iori is null!"); thingGraph = register(new ThingGraph()); } return(thingGraph); }
public static bool HasBackGraph(this IGraphSceneMesh <IVisual, IVisualEdge> mesh) { var backHandler = mesh.BackHandler <IThing, ILink> (); return(backHandler.BackGraphs.Any()); }