/// <summary> /// Initializes a new instance of the <see cref="CommandViewItem" /> class. /// </summary> /// <param name="commandItemBase">The command item.</param> /// <param name="commandViewFactory">The command view factory.</param> /// <param name="commandView">The command view.</param> public CommandViewItem(ICommandItemBase commandItemBase, ICommandViewFactory commandViewFactory, CommandView commandView) { this.commandViewFactory = commandViewFactory; this.commandItemBase = commandItemBase; this.commandView = commandView; if (this.commandItemBase != null) { this.commandItemBase.CommandItemChanged += this.CommandItemOnCommandItemChanged; } }
public object CreateView(ICommandViewFactory commandViewFactory) { if (ViewType == null) { return(null); } object view = commandViewFactory.Create(ViewType); if (view == null) { throw new InvalidCommandException(); } return(view); }
/// <summary> /// Registers the command view factory. /// </summary> /// <param name="key">The key.</param> /// <param name="handler">The handler.</param> public static void RegisterCommandViewFactory(Type key, ICommandViewFactory handler) { if (handler == null) { throw new ArgumentNullException(@"handler"); } lock (CommandViewFactories) { if (CommandViewFactories.ContainsKey(key)) { CommandViewFactories.Remove(key); } CommandViewFactories.Add(key, handler); } }
/// <summary> /// Initializes a new instance of the <see cref="CommandView" /> class. /// </summary> /// <param name="scope">The scope of the command view. This is the type which defines the concrete command view.</param> /// <param name="commandProvider">The command provider.</param> /// <param name="commandViewFactory">The command view factory.</param> public CommandView(object scope, ICommandProvider commandProvider, ICommandViewFactory commandViewFactory) { if (commandProvider == null) { throw new ArgumentNullException(@"commandProvider"); } this.scope = scope; this.commandProvider = commandProvider; this.commandViewFactory = commandViewFactory; if (this.commandProvider != null) { this.commandProvider.CommandAdded += this.CommandProviderOnCommandAdded; this.commandProvider.CommandChanged += this.CommandProviderOnCommandChanged; this.commandProvider.CommandRemoved += this.CommandProviderOnCommandRemoved; } foreach (var commandProviderItem in commandProvider.Commands) { this.commandViewFactory.AddProviderCommand(commandProviderItem, this); } }
public CommandMiddleware(CommandPool commandPool, ICommandModelFactory commandModelFactory, ICommandViewFactory commandViewFactory) { this.commandPool = commandPool ?? throw new ArgumentNullException(nameof(commandPool)); this.commandModelFactory = commandModelFactory ?? throw new ArgumentNullException(nameof(commandModelFactory)); this.commandViewFactory = commandViewFactory ?? throw new ArgumentNullException(nameof(commandViewFactory)); }