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); } }
//Asks CommandBuilder to create an instance for Command public Flag(string name) { command = builder.Create(name); commandArgs = new List <string>(); }
public void Handle(NothingDependentViewModelCommand command, string errors) { _bus.Send(_builder.Create(command)); }