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

            PathSetSet.GetMessagePathSet <TMessage>().AddMessagePath(path);
            PathAdded?.Invoke(path);
            return(path);
        }
Ejemplo n.º 2
0
            internal MessagePath(Type location, string description, LogEnum logType, Action <TMessage> action, PathId pathId, int viaTimesLimit)
            {
                if (viaTimesLimit == 0)
                {
                    throw new InvalidProgramException("消息路径的viaTimesLimit不能为0,可以为负数表示不限制通过次数或为正数表示限定通过次数,但不能为0");
                }
                _path          = action;
                _isEnabled     = true;
                _viaTimesLimit = viaTimesLimit;

                MessageType = typeof(TMessage);
                Location    = location;
                Path        = $"{location.FullName}[{MessageType.FullName}]";
                Description = description;
                LogType     = logType;
                PathId      = pathId;
                CreatedOn   = DateTime.Now;
            }
Ejemplo n.º 3
0
        public static MessagePath <TMessage> AddMessagePath(IMessagePathHub hub, Type location, string description, LogEnum logType, Action <TMessage> action, PathId pathId, int viaTimesLimit = -1)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }
            MessagePath <TMessage> path = new MessagePath <TMessage>(location, description, logType, action, pathId, viaTimesLimit);

            hub.AddPath(path);
            return(path);
        }