예제 #1
0
 public static IHandlerId Create(Type messageType, Type location, Guid id, string description, LogEnum logType)
 {
     if (_dicById.ContainsKey(id))
     {
         var item = _dicById[id];
         item.MessageType = messageType;
         item.Location    = location;
         item.Description = description;
         Global.Happened(new HandlerIdUpdatedEvent(item));
         return(item);
     }
     else
     {
         var item = new HandlerId {
             MessageType = messageType,
             Location    = location,
             Id          = id,
             Description = description,
             LogType     = logType
         };
         _dicById.Add(id, item);
         if (Global.IsPublishHandlerIdAddedEvent)
         {
             Global.Happened(new HandlerIdAddedEvent(item));
         }
         return(item);
     }
 }
예제 #2
0
        public static IHandlerId Create(Type messageType, Type location, string description, LogEnum logType)
        {
            string path = $"{location.FullName}[{messageType.FullName}]";

            if (SDicById.ContainsKey(path))
            {
                var item = SDicById[path];
                item.MessageType = messageType;
                item.Location    = location;
                item.Description = description;
                item.HandlerPath = path;
                return(item);
            }
            else
            {
                var item = new HandlerId {
                    MessageType = messageType,
                    Location    = location,
                    HandlerPath = path,
                    Description = description,
                    LogType     = logType
                };
                SDicById.Add(path, item);
                return(item);
            }
        }
예제 #3
0
        // 修建消息(命令或事件)的运动路径
        public static DelegateHandler <TMessage> Path <TMessage>(string description, LogEnum logType, Action <TMessage> action)
        {
            StackTrace ss = new StackTrace(false);
            // 0是Path,1是Accpt或On,2是当地
            Type       location  = ss.GetFrame(2).GetMethod().DeclaringType;
            IHandlerId handlerId = HandlerId.Create(typeof(TMessage), location, description, logType);

            return(SMessageDispatcher.Register(handlerId, action));
        }
예제 #4
0
        public static DelegateHandler <TMessage> Access <TMessage>(
            Guid id, string description, LogEnum logType, Action <TMessage> action)
        {
            StackTrace ss        = new StackTrace(false);
            Type       location  = ss.GetFrame(1).GetMethod().DeclaringType;
            IHandlerId handlerId = HandlerId.Create(typeof(TMessage), location, id, description, logType);

            return(MessageDispatcher.Register(handlerId, action));
        }
예제 #5
0
        public static IHandlerId Create(Type messageType, Type location, string description, LogEnum logType)
        {
            string path = $"{location.FullName}[{messageType.FullName}]";
            var    item = new HandlerId {
                MessageType = messageType,
                Location    = location,
                HandlerPath = path,
                Description = description,
                LogType     = logType
            };

            return(item);
        }