/// <see cref="ICommandExecutorPluginInstall.RegisterCommandExecutionFactory"/> public void RegisterCommandExecutionFactory(ICommandExecutionFactory factory) { if (factory == null) { throw new ArgumentNullException("factory"); } if (factory.CommandType != null && string.IsNullOrWhiteSpace(factory.CommandType)) { throw new ArgumentException("The command type of the factory shall be null or a non-empty string!", "factory"); } if (string.IsNullOrWhiteSpace(factory.EntityType)) { throw new ArgumentException("The entity type of the factory cannot be null or whitespace!", "factory"); } this.RegisterCommandExecutionFactoryImpl(factory.CommandType ?? string.Empty, factory.EntityType, factory); }
public DragDropProvider(ICombineableFactory commandFactory, ICommandExecutionFactory commandExecutionFactory, TreeListView treeView) { _commandFactory = commandFactory; _commandExecutionFactory = commandExecutionFactory; _treeView = treeView; _treeView.IsSimpleDragSource = false; _treeView.DragSource = this; _treeView.IsSimpleDropSink = true; ((SimpleDropSink)_treeView.DropSink).CanDrop += DragDropProvider_CanDrop; ((SimpleDropSink)_treeView.DropSink).Dropped += DragDropProvider_Dropped; _treeView.ModelCanDrop += ModelCanDrop; _treeView.ModelDropped += ModelDropped; }
/// <summary> /// Selects the command execution factories to be used for the given entity set. /// </summary> /// <param name="commandType">The type of the command.</param> /// <param name="entitySet">The set of entities.</param> /// <returns> /// The list of the command execution factories to be used or an empty list if there is at least 1 entity that is not /// able to execute the given command. /// </returns> private IEnumerable <ICommandExecutionFactory> SelectFactories(string commandType, IEnumerable <Entity> entitySet) { if (!this.commandExecutionFactories.ContainsKey(commandType)) { return(new RCSet <ICommandExecutionFactory>()); } Dictionary <string, ICommandExecutionFactory> factoriesPerTypes = this.commandExecutionFactories[commandType]; RCSet <ICommandExecutionFactory> retList = new RCSet <ICommandExecutionFactory>(); foreach (Entity entity in entitySet) { if (!factoriesPerTypes.ContainsKey(entity.ElementType.Name)) { return(new RCSet <ICommandExecutionFactory>()); } ICommandExecutionFactory factory = factoriesPerTypes[entity.ElementType.Name]; retList.Add(factory); } return(retList); }
/// <summary> /// The internal implementation of the RegisterCommandExecutionFactory method. /// </summary> private void RegisterCommandExecutionFactoryImpl(string commandType, string entityType, ICommandExecutionFactory factory) { /// Create a new group of command execution factories for the given command type if doesn't exist. if (!this.commandExecutionFactories.ContainsKey(commandType)) { this.commandExecutionFactories[commandType] = new Dictionary <string, ICommandExecutionFactory>(); } /// Check if another factory has already been registered for the given command and entity type. if (this.commandExecutionFactories[commandType].ContainsKey(entityType)) { throw new InvalidOperationException(string.Format("Command execution factory for command type '{0}' and entity type '{1}' has already been registered!", commandType, entityType)); } /// Register the new factory. this.commandExecutionFactories[commandType][entityType] = factory; }