/// <summary> /// Initializes a new instance of the <see cref="MessageProcessor"/> class. /// </summary> /// <param name="msgID">ID of the message to process. Must be non-zero.</param> /// <param name="methodDelegate">Delegate to the processing method.</param> /// <exception cref="ArgumentNullException"><paramref name="methodDelegate" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="msgID"/> is zero.</exception> public MessageProcessor(MessageProcessorID msgID, MessageProcessorHandler methodDelegate) { if (methodDelegate == null) { throw new ArgumentNullException("methodDelegate"); } if (msgID.GetRawValue() == 0) { throw new ArgumentOutOfRangeException("msgID", "The message ID may not be zero."); } _msgID = msgID; _call = methodDelegate; }
/// <summary> /// Gets the <see cref="IMessageProcessor"/> with the given ID. This will only ever return the <see cref="IMessageProcessor"/> /// for the method that was specified using a <see cref="MessageHandlerAttribute"/>. Is intended to only be used by /// <see cref="MessageProcessorManager.GetMessageProcessor"/> to allow for access of the <see cref="IMessageProcessor"/>s loaded /// through the attribute. /// </summary> /// <param name="msgID">The ID of the message.</param> /// <returns>The <see cref="IMessageProcessor"/> for the <paramref name="msgID"/>, or null if an invalid ID.</returns> protected IMessageProcessor GetInternalMessageProcessor(MessageProcessorID msgID) { return(_processors[msgID.GetRawValue()]); }