예제 #1
0
        /// <summary>
        /// Dispatches a message to the given target.
        /// </summary>
        public Messenger Dispatch <T>(MsgTarget inTarget, MsgType <T> inType, T inArgs)
        {
            if (m_Impl.IsValid)
            {
                switch (inTarget.Target)
                {
                case MsgTarget.Mode.Self:
                    return(Send(inType, inArgs));

                case MsgTarget.Mode.Other:
                    if (inTarget.Object == null)
                    {
                        throw new ArgumentNullException("Null target for MsgTarget.Mode.Other!");
                    }
                    else
                    {
                        return(Send(inTarget.Object, inType, inArgs));
                    }

                case MsgTarget.Mode.All:
                    return(Broadcast(inType, inArgs));

                default:
                    throw new InvalidOperationException("Unknown value for MsgTarget.Mode: " + inTarget.Target.ToString());
                }
            }
            return(this);
        }
예제 #2
0
 /// <summary>
 /// Dispatches a message to the given target.
 /// </summary>
 public Messenger Dispatch(MsgTarget inTarget, MsgCall inCall)
 {
     if (m_Impl.IsValid)
     {
         return(Dispatch(inTarget, (MsgType <object>)inCall.Type, inCall.Args));
     }
     return(this);
 }