public NonGenericCommandFactory( ICommandFactory commandFactory, IViewModel viewModel, CommandMethods methods) { this.viewModel = viewModel; this.methods = methods; this.commandFactory = commandFactory; }
public GenericCommandFactory( ICommandFactory commandFactory, INotifyPropertyChanged viewModel, CommandMethods methods, Type parameterType) { this.viewModel = viewModel; this.methods = methods; this.parameterType = parameterType; this.commandFactory = commandFactory; }
public ICommand Create(INotifyPropertyChanged viewModel, CommandMethods methods) { if (methods.HasErrors) { return null; } var parameter = methods.ActionMethod.MethodInfo.GetParameters().SingleOrDefault(); var factory = parameter.IsNull() ? new NonGenericCommandFactory(commandFactory, viewModel, methods) : (IFactory<ICommand>)new GenericCommandFactory(commandFactory, viewModel, methods, parameter.ParameterType); return factory.Create(); }
public ICommand Create(IViewModel viewModel, CommandMethods methods) { if (methods.HasErrors) { return(null); } var parameter = methods.ActionMethod.MethodInfo.GetParameters().SingleOrDefault(); IFactory <ICommand> factory; if (parameter.IsNull()) { factory = nonGenericCommandFactory(viewModel, methods); } else { factory = genericCommandFactory(viewModel, methods, parameter.ParameterType); } return(factory.Create()); }