Ejemplo n.º 1
0
 /// <summary>
 /// 隧道触发
 /// </summary>
 public void TriggerTunneling(YuriRoutedEvent evt)
 {
     evt.RaiseOnRouterAcceptEvent(this, null);
     evt.RaiseProcessedEvent(this, null);
     if (this.IsSwallow)
     {
         evt.RaiseRouterSwallowedEvent(this, null);
     }
     else
     {
         this.Children?.ForEach(cr => cr.TriggerTunneling(evt));
     }
     evt.RaiseOnRouterRoutedEvent(this, null);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 冒泡触发
 /// </summary>
 public void TriggerBubbling(YuriRoutedEvent evt)
 {
     evt.RaiseOnRouterAcceptEvent(this, null);
     evt.RaiseProcessedEvent(this, null);
     if (this.IsSwallow)
     {
         evt.RaiseRouterSwallowedEvent(this, null);
     }
     else
     {
         this.Parent?.TriggerBubbling(evt);
     }
     evt.RaiseOnRouterRoutedEvent(this, null);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 向一个路由器发送一个消息
        /// </summary>
        /// <param name="routerName">起始路由器名字</param>
        /// <param name="evt">路由消息</param>
        /// <returns>起始路由是否存在</returns>
        public static bool Send(string routerName, YuriRoutedEvent evt)
        {
            if (RouterManager.ExistRouter(routerName))
            {
                var router = RouterManager.RouterTable[routerName];
                switch (evt.Type)
                {
                case YuriRoutedType.Direct:
                    router.TriggerDirect(evt);
                    break;

                case YuriRoutedType.Bubbling:
                    router.TriggerBubbling(evt);
                    break;

                case YuriRoutedType.Tunneling:
                    router.TriggerTunneling(evt);
                    break;
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 直接触发
 /// </summary>
 public void TriggerDirect(YuriRoutedEvent evt)
 {
     evt.RaiseOnRouterAcceptEvent(this, null);
     evt.RaiseProcessedEvent(this, null);
     evt.RaiseOnRouterRoutedEvent(this, null);
 }