public void PerformEvent(IRoutingEventArgs args) { IChainRoutingNodeProxy proxy = firstProxy; while (proxy != null) { proxy.HandleEvent(args); switch (args.RoutingState) { case RoutingState.Start: args.RoutingState = RoutingState.Normal; break; case RoutingState.Skip: args.RoutingState = RoutingState.Continue; continue; case RoutingState.Handled: break; default: break; } } }
public void RemoveNode(object target, MatchingStrategy strategy, bool removeSubsequent) { IChainRoutingNodeProxy removeProxy = MatchinProxy(target, strategy); IChainRoutingNodeProxy nextProxy = removeSubsequent ? null : removeProxy.NextProxy; removeProxy.LastProxy.NextProxy = nextProxy; }
public void AddNode(object node, object identify) { IChainRoutingNodeProxy proxy = CreateProxy(node, identify); IChainRoutingNodeProxy lastProxy = GetLastProxy(); lastProxy.NextProxy = proxy; proxy.LastProxy = lastProxy; }
public void InsertNode(object node, object identify, object previous, MatchingStrategy strategy) { IChainRoutingNodeProxy proxy = CreateProxy(node, identify); IChainRoutingNodeProxy lastProxy = MatchinProxy(previous, strategy); IChainRoutingNodeProxy nextProxy = lastProxy.NextProxy; lastProxy.NextProxy = proxy; proxy.LastProxy = lastProxy; proxy.NextProxy = nextProxy; nextProxy.LastProxy = proxy; }
public void ReplaceNode(object node, object identify) { IChainRoutingNodeProxy proxy = CreateProxy(node, identify); IChainRoutingNodeProxy replaceProxy = MatchinProxy(identify, MatchingStrategy.Identify); IChainRoutingNodeProxy lastProxy = replaceProxy.LastProxy; IChainRoutingNodeProxy nextProxy = replaceProxy.NextProxy; lastProxy.NextProxy = proxy; proxy.LastProxy = lastProxy; proxy.NextProxy = nextProxy; nextProxy.LastProxy = proxy; }
/// <summary> /// 匹配节点 /// </summary> /// <param name="target">匹配目标</param> /// <param name="strategy">匹配模式</param> /// <returns></returns> protected IChainRoutingNodeProxy MatchinProxy(object target, MatchingStrategy strategy) { if (firstProxy == null) { return(null); } IChainRoutingNodeProxy nowProxy = firstProxy; switch (strategy) { case MatchingStrategy.Deep: int nowDeep = 0; int targetDeep = (int)target; while (firstProxy.NextProxy != null) { if (nowDeep == targetDeep) { return(nowProxy); } nowProxy = nowProxy.NextProxy; nowDeep += 1; } return(nowProxy); case MatchingStrategy.Identify: while (firstProxy.NextProxy != null) { if (nowProxy.ProxyIdentify == target) { return(nowProxy); } nowProxy = nowProxy.NextProxy; } return(nowProxy); case MatchingStrategy.Object: while (firstProxy.NextProxy != null) { if (nowProxy.ProxyNode == target) { return(nowProxy); } nowProxy = nowProxy.NextProxy; } return(nowProxy); default: return(null); } }
public void RemoveNode() { IChainRoutingNodeProxy removeNode = GetLastProxy(); removeNode.LastProxy.NextProxy = null; }