Example #1
0
        protected virtual IEnumerable <string> AssignCommand(
            IViewModel viewModel,
            PropertyInfo commandProperty)
        {
            try
            {
                var methods = commandConvention.Get(commandProperty.ReflectedType, commandProperty);

                var command = commandBuilder.Create(viewModel, methods);

                if (command == null)
                {
                    return(methods.Errors);
                }

                if (commandProperty.DeclaringType != commandProperty.ReflectedType)
                {
                    commandProperty = commandProperty?.DeclaringType?.GetProperty(commandProperty.Name);
                }

                commandProperty.SetValue(viewModel, command);

                return(methods.Errors);
            }
            catch (Exception exception)
            {
                var message = $"Cannot assign the command {commandProperty?.Name} of viewmodel {viewModel.GetType().FullName}. Check the Set method exists.";

                throw new InvalidOperationException(message, exception);
            }
        }
Example #2
0
 //Asks CommandBuilder to create an instance for Command
 public Flag(string name)
 {
     command     = builder.Create(name);
     commandArgs = new List <string>();
 }
Example #3
0
 public void Handle(NothingDependentViewModelCommand command, string errors)
 {
     _bus.Send(_builder.Create(command));
 }