示例#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);
        }
示例#2
0
        /// <summary>
        /// Get the least busy station for a plane(depends on the route)
        /// </summary>
        /// <param name="plane">plane to choose the next route for</param>
        /// <returns>least busy station for the plane</returns>
        private LogicStation GetBestStation(IRouteable plane)
        {
            var nextStationNumbers = plane.Route.GetNextAvailableRoute(this.StationNumber);

            if (!nextStationNumbers.Any())
            {
                throw new Exception("Could not be empty, if we reach the end we receive 0");
            }
            else if (nextStationNumbers.Any(staionNum => staionNum == 0)) //if it reached the end
            {
                return(null);
            }
            else
            {
                var nextStations = GetStations(nextStationNumbers);
                return(LogicStation.GetBestStation(nextStations));
            }
        }
示例#3
0
 /// <summary>
 /// 引发路由器处理消息完毕时的事件
 /// </summary>
 /// <param name="sender">触发事件的路由器</param>
 /// <param name="e">参数包装</param>
 public void RaiseProcessedEvent(IRouteable sender, EventArgs e)
 {
     this.OnProcessed?.Invoke(sender, e);
 }
示例#4
0
 /// <summary>
 /// 引发路由器吞下消息时事件
 /// </summary>
 /// <param name="sender">触发事件的路由器</param>
 /// <param name="e">参数包装</param>
 public void RaiseRouterSwallowedEvent(IRouteable sender, EventArgs e)
 {
     this.OnRouterSwallowed?.Invoke(sender, e);
 }
示例#5
0
 /// <summary>
 /// 引发被路由接收并处理时事件
 /// </summary>
 /// <param name="sender">触发事件的路由器</param>
 /// <param name="e">参数包装</param>
 public void RaiseOnRouterAcceptEvent(IRouteable sender, EventArgs e)
 {
     this.OnRouterAccept?.Invoke(sender, e);
 }
 /// <summary>
 /// 引发被路由即将开始转发给子路由时事件
 /// </summary>
 /// <param name="sender">触发事件的路由器</param>
 /// <param name="e">参数包装</param>
 public void RaiseOnRouterRoutedEvent(IRouteable sender, EventArgs e)
 {
     OnRouterRouted?.Invoke(sender, e);
 }