/// <summary> /// Creates a new <see cref="Message"/>, encapsulating the data from the payload. /// </summary> /// <param name="payload">The payload to be encapsulated.</param> /// <param name="sourceChannel">The name of the channel the message is being generated on.</param> /// <returns>A <see cref="MessageParseResult"/> containing the result of the operation.</returns> internal static MessageParseResult CreateFromUserInput(string payload, string sourceChannel) { MessageParseResult retval = null; string className = GetClassNameFromUserCommand(payload); if (!string.IsNullOrEmpty(className)) { Message message = (Message)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(string.Format("Yaircc.Net.IRC.{0}", className)); message.ChannelName = sourceChannel; ParseResult parseResult = message.TryParse(payload); retval = new MessageParseResult(parseResult.Success, parseResult.Message, message); } else { Message message = new Message(); ParseResult parseResult = message.TryParse(payload); retval = new MessageParseResult(parseResult.Success, parseResult.Message, message); } return retval; }
/// <summary> /// Creates a new <see cref="Message"/>, encapsulating the data from the payload. /// </summary> /// <param name="payload">The payload to be encapsulated.</param> /// <param name="sourceChannel">The name of the channel the message is being generated on.</param> /// <returns>A <see cref="MessageParseResult"/> containing the result of the operation.</returns> internal static MessageParseResult CreateFromUserInput(string payload, string sourceChannel) { MessageParseResult retval = null; string className = GetClassNameFromUserCommand(payload); if (!string.IsNullOrEmpty(className)) { Message message = (Message)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(string.Format("Yaircc.Net.IRC.{0}", className)); message.ChannelName = sourceChannel; ParseResult parseResult = message.TryParse(payload); retval = new MessageParseResult(parseResult.Success, parseResult.Message, message); } else { Message message = new Message(); ParseResult parseResult = message.TryParse(payload); retval = new MessageParseResult(parseResult.Success, parseResult.Message, message); } return(retval); }