Ejemplo n.º 1
0
        /// <inheritdoc />
        public virtual void Register <TMessage>(object recipient, ThreadCallbackOption threadCallbackOption, object token, bool receiveDerivedMessagesToo, Action <TMessage> action)
        {
            var messageType = typeof(TMessage);
            var recipients  = receiveDerivedMessagesToo ? _derivedRegistrations : _onlyDirectRegistrations;
            List <WeakTokenedAction> list;

            if (!recipients.ContainsKey(messageType))
            {
                list = new List <WeakTokenedAction>();
                recipients.TryAdd(messageType, list);
            }
            else
            {
                list = recipients[messageType];
            }
            var weakAction = new WeakAction <TMessage>(recipient, action);
            var item       = new WeakTokenedAction(weakAction, token, threadCallbackOption);

            list.Add(item);
            RequestCleanup();
        }
Ejemplo n.º 2
0
 /// <inheritdoc />
 public virtual void Register <TMessage>(object recipient, ThreadCallbackOption threadCallbackOption, Action <TMessage> action)
 {
     Register(recipient, threadCallbackOption, null, false, action);
 }
Ejemplo n.º 3
0
 public WeakTokenedAction(WeakAction action, object token, ThreadCallbackOption threadCallback = ThreadCallbackOption.Sender)
 {
     Action = action;
     Token  = token;
     ThreadCallbackOption = threadCallback;
 }