Esempio n. 1
0
        /// <summary>
        /// 添加一个路由器
        /// </summary>
        /// <param name="router">路由器的引用</param>
        /// <returns>是否为替换操作</returns>
        public static bool SetRouter(IRouteable router)
        {
            bool replaced = RouterManager.ExistRouter(router.Name);

            RouterManager.RouterTable[router.Name] = router;
            return(replaced);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
 /// <summary>
 /// 获取一个路由器
 /// </summary>
 /// <param name="name">路由器的名字</param>
 /// <returns>路由器的引用</returns>
 public static IRouteable GetRouter(string name)
 {
     return(RouterManager.ExistRouter(name) ? RouterManager.RouterTable[name] : null);
 }