public static void RegisterVertexChangeListeners(IVertex PlatformClassVertex, VertexChange action, string[] watchList) { PlatformClassVertexChangeListener listener = new PlatformClassVertexChangeListener(watchList); listener.PlatformClassVertex = PlatformClassVertex; listener.Change += action; PlatformClassVertex.Change += new VertexChange(listener.Listener); IVertex AttributeVertexes = PlatformClassVertex.GetAll(@"$Is:{$Inherits:$PlatformClass}\Selector:"); foreach (IEdge e in AttributeVertexes) { foreach (IEdge ee in PlatformClassVertex.GetAll(e.To.Value + ":")) { GraphUtil.AddHandlerIfDelegateListDoesNotContainsIt(ee.To, listener.Listener); foreach (string metaFromWatchList in listener.WatchList) { if (GeneralUtil.CompareStrings(ee.Meta.Value, metaFromWatchList)) { foreach (IEdge eee in ee.To) { GraphUtil.AddHandlerIfDelegateListDoesNotContainsIt(eee.To, listener.Listener); } } } } } }
public void Listener(object sender, VertexChangeEventArgs e) { if (CheckSender(sender) && (e.Type == VertexChangeType.EdgeAdded) && (!GeneralUtil.CompareStrings(e.Edge.Meta.Value, "$Is"))) { IVertex AttributeVertexes = ((IVertex)sender).GetAll(@"$Is:\Selector:"); //IVertex AttributeVertexes = ((IVertex)sender).GetAll(@"$Is:{$Inherits:$PlatformClass}\Selector:"); foreach (IEdge ed in AttributeVertexes) { if (e.Edge.Meta == ed.To) { GraphUtil.AddHandlerIfDelegateListDoesNotContainsIt(e.Edge.To, this.Listener); } } foreach (string metaFromWatchList in WatchList) { if (((string)e.Edge.Meta.Value) == metaFromWatchList) { GraphUtil.AddHandlerIfDelegateListDoesNotContainsIt(e.Edge.To, this.Listener); foreach (IEdge ee in e.Edge.To) { GraphUtil.AddHandlerIfDelegateListDoesNotContainsIt(ee.To, this.Listener); } } } } foreach (string metaFromWatchList in WatchList) { if ((sender == PlatformClassVertex.Get(metaFromWatchList + ":")) && (e.Type == VertexChangeType.EdgeAdded) && (!GeneralUtil.CompareStrings(e.Edge.Meta.Value, "$Is"))) { GraphUtil.AddHandlerIfDelegateListDoesNotContainsIt(e.Edge.To, this.Listener); } } if (CheckSender(sender) && (e.Type == VertexChangeType.EdgeRemoved) && (!GeneralUtil.CompareStrings(e.Edge.Meta.Value, "$Is"))) { IVertex AttributeVertexes = ((IVertex)sender).GetAll(@"$Is:\Selector:"); //IVertex AttributeVertexes = ((IVertex)sender).GetAll(@"$Is:{$Inherits:$PlatformClass}\Selector:"); foreach (IEdge ed in AttributeVertexes) { if (e.Edge.Meta == ed.To) { e.Edge.To.Change -= new VertexChange(this.Listener); } } foreach (string metaFromWatchList in WatchList) { if (((string)e.Edge.Meta.Value) == metaFromWatchList) { e.Edge.To.Change -= new VertexChange(this.Listener); foreach (IEdge ee in e.Edge.To) { ee.To.Change -= new VertexChange(this.Listener); } } } } foreach (string metaFromWatchList in WatchList) { if ((sender == PlatformClassVertex.Get(metaFromWatchList + ":")) && (e.Type == VertexChangeType.EdgeRemoved) && (!GeneralUtil.CompareStrings(e.Edge.Meta.Value, "$Is"))) { e.Edge.To.Change -= new VertexChange(this.Listener); } } if (Change != null) { Change(sender, e); } }