Ejemplo n.º 1
0
            internal MessagePath(Type location, string description, LogEnum logType, Action <TMessage> action, PathId pathId, PathPriority priority, int viaTimesLimit)
            {
                if (viaTimesLimit == 0)
                {
                    throw new InvalidProgramException("消息路径的viaTimesLimit不能为0,可以为负数表示不限制通过次数或为正数表示限定通过次数,但不能为0");
                }
                _action        = action;
                _isEnabled     = true;
                _viaTimesLimit = viaTimesLimit;
                var    messageType = typeof(TMessage);
                string path        = $"{location.FullName}[{messageType.FullName}]";

                MessageType = messageType;
                Location    = location;
                PathName    = path;
                Description = description;
                LogType     = logType;
                PathId      = pathId;
                Priority    = priority;
                CreatedOn   = DateTime.Now;
            }
Ejemplo n.º 2
0
        // 因为是上下文路径,无需返回路径标识
        public static void BuildEventPath <TEvent>(string description, LogEnum logType, Type location, PathPriority priority, Action <TEvent> path)
            where TEvent : IEvent
        {
            var messagePathId = VirtualRoot.BuildMessagePath(description, logType, location, priority, path);

            _contextPathIds.Add(messagePathId);
        }
Ejemplo n.º 3
0
        public static IMessagePathId BuildViaTimesLimitPath <TMessage>(this Window window, string description, LogEnum logType, int viaTimesLimit, Type location, PathPriority priority, Action <TMessage> path)
            where TMessage : IMessage
        {
            if (WpfUtil.IsInDesignMode)
            {
                return(null);
            }
            if (window.Resources == null)
            {
                window.Resources = new ResourceDictionary();
            }
            List <IMessagePathId> messagePathIds = (List <IMessagePathId>)window.Resources[messagePathIdsResourceKey];

            if (messagePathIds == null)
            {
                messagePathIds = new List <IMessagePathId>();
                window.Resources.Add(messagePathIdsResourceKey, messagePathIds);
                window.Closed += UiElement_Closed;;
            }
            var messagePathId = VirtualRoot.BuildViaTimesLimitPath(description, logType, viaTimesLimit, location, priority, path);

            messagePathIds.Add(messagePathId);
            return(messagePathId);
        }
Ejemplo n.º 4
0
        public IMessagePathId AddPath <TMessage>(Type location, string description, LogEnum logType, PathId pathId, PathPriority priority, Action <TMessage> action, int viaTimesLimit = -1)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }
            MessagePath <TMessage> path = new MessagePath <TMessage>(location, description, logType, action, pathId, priority, viaTimesLimit);

            PathSetSet.GetMessagePathSet <TMessage>().AddMessagePath(path);
            PathAdded?.Invoke(path);
            return(path);
        }
Ejemplo n.º 5
0
 public static IMessagePathId BuildEventPath <TEvent>(string description, LogEnum logType, Type location, PathPriority priority, Action <TEvent> path)
     where TEvent : IEvent
 {
     return(BuildMessagePath(description, logType, location, priority, path));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 消息通过路径指定的次数后路径即消失
 /// </summary>
 public static IMessagePathId BuildViaTimesLimitPath <TMessage>(string description, LogEnum logType, int viaTimesLimit, Type location, PathPriority priority, Action <TMessage> path)
 {
     return(MessageHub.AddPath(location, description, logType, pathId: PathId.Empty, priority, path, viaTimesLimit));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 消息通过路径一次后路径即消失。
 /// 注意该路径具有特定的路径标识pathId,pathId可以看作是路径的形状,只有和该路径的形状相同的消息才能通过路径。
 /// </summary>
 public static IMessagePathId BuildOnecePath <TMessage>(string description, LogEnum logType, PathId pathId, Type location, PathPriority priority, Action <TMessage> path)
 {
     return(MessageHub.AddPath(location, description, logType, pathId, priority, path, viaTimesLimit: 1));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 修建消息的运动路径
 /// </summary>
 public static IMessagePathId BuildMessagePath <TMessage>(string description, LogEnum logType, Type location, PathPriority priority, Action <TMessage> path)
 {
     return(MessageHub.AddPath(location.FullName, description, logType, pathId: PathId.Empty, priority, path));
 }