private IRequest DeserializeCommand(GenericCommand genericCommand, Type commandType)
        {
            var noneOptArguments = genericCommand.NoneOptArguments.ToDictionary(x => x, x => string.Empty);
            List <Dictionary <string, string> > allArguments = new List <Dictionary <string, string> > {
                genericCommand.Arguments, noneOptArguments
            };
            var mergedArguments = allArguments.SelectMany(x => x)
                                  .ToLookup(pair => pair.Key, pair => pair.Value)
                                  .ToDictionary(group => group.Key, group => group.First());

            var json = JsonConvert.SerializeObject(mergedArguments);

            return((IRequest)JsonConvert.DeserializeObject(json, commandType));
        }
        private IRequest Reflect(GenericCommand genericCommand, Type commandType)
        {
            IRequest instance = (IRequest)Activator.CreateInstance(commandType);

            if (instance != null)
            {
                var properties = instance.GetType().GetProperties();
                foreach (var keyValue in genericCommand.Arguments)
                {
                    var prop = properties.FirstOrDefault(x => x.Name.ToLower().Equals(keyValue.Key));
                    if (prop != null)
                    {
                        var t = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;

                        var value = (keyValue.Value == null) ? null : Convert.ChangeType(keyValue.Value, t);
                        prop.SetValue(instance, value);
                    }
                }
            }
            return(instance);
        }
 public StructuredArgumentErrorException(GenericCommand req)
 {
     this.req = req;
 }