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); }
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; }
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); }