/// <summary> /// 触发,执行事件 /// </summary> /// <param name="event"></param> public void Process(ZookeeperEvent @event) { try { switch (@event.Type) { case ZookeeperEvent.EventType.NodeChildrenChanged: NodeChildrenChanged?.Invoke(@event); break; case ZookeeperEvent.EventType.NodeCreated: NodeCreated?.Invoke(@event); break; case ZookeeperEvent.EventType.NodeDeleted: NodeDeleted?.Invoke(@event); break; case ZookeeperEvent.EventType.NodeDataChanged: NodeDataChanged?.Invoke(@event); break; } AllTypeChanged?.Invoke(@event); } catch { } }
internal void RaiseNodeDeleted(FileSystemEntryId id) { NodeDeleted?.Invoke(id); }
void IEventSink.NotifyNodeRemoved(TreePosition parent, int childIndex, TreePosition child) { NodeDeleted?.Invoke(this, new TreeNodeChildEventArgs(parent, childIndex, child)); }
/// <summary> /// Overridable method to handle deletion of nodes /// </summary> /// <param name="node"></param> protected virtual void OnNodeDeleted(GraphNode node) { NodeDeleted?.Invoke(this, new NodeDeletedEventArgs(node)); }
/// <summary> /// When Collection even is generated, this method is called /// </summary> /// <param name="args">Simias event details</param> private void OnCollectionEvent(SimiasEventArgs args) { try { NodeEventArgs nodeArgs = args as NodeEventArgs; if (nodeArgs != null) { if (applyNodeFilter(nodeArgs)) { EventType changeType = (EventType)Enum.Parse(typeof(EventType), (string)nodeArgs.EventData, false); switch (changeType) { case EventType.NodeChanged: if (NodeChanged != null) { Delegate[] cbList = NodeChanged.GetInvocationList(); foreach (NodeEventHandler cb in cbList) { try { cb(nodeArgs); } catch (Exception ex) { logger.Debug(ex, "Delegate {0}.{1} failed", cb.Target, cb.Method); NodeChanged -= cb; } } } break; case EventType.NodeCreated: if (NodeCreated != null) { Delegate[] cbList = NodeCreated.GetInvocationList(); foreach (NodeEventHandler cb in cbList) { try { cb(nodeArgs); } catch (Exception ex) { logger.Debug(ex, "Delegate {0}.{1} failed", cb.Target, cb.Method); NodeCreated -= cb; } } } break; case EventType.NodeDeleted: if (NodeDeleted != null) { Delegate[] cbList = NodeDeleted.GetInvocationList(); foreach (NodeEventHandler cb in cbList) { try { cb(nodeArgs); } catch (Exception ex) { logger.Debug(ex, "Delegate {0}.{1} failed", cb.Target, cb.Method); NodeDeleted -= cb; } } } break; case EventType.NoAccess: if (NoAccess != null) { Delegate[] cbList = NoAccess.GetInvocationList(); foreach (NodeEventHandler cb in cbList) { try { cb(nodeArgs); } catch (Exception ex) { logger.Debug(ex, "Delegate {0}.{1} failed", cb.Target, cb.Method); NodeDeleted -= cb; } } } break; } } } } catch (Exception ex) { new SimiasException(args.ToString(), ex); } }