/// <summary> /// Creates a new instance of <see cref="ContextMenuBuilder"/>. /// </summary> /// <param name="featureCommandHandler">The <see cref="IApplicationFeatureCommands"/> from which to obtain /// information to render and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="importCommandHandler">The <see cref="IImportCommandHandler"/> from which to obtain /// information to render and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="exportCommandHandler">The <see cref="IExportCommandHandler"/> from which to obtain /// information to render and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="updateCommandHandler">The <see cref="IUpdateCommandHandler"/> from which to obtain /// information to render and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="viewCommands">The <see cref="IViewCommands"/> from which to obtain information to render /// and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="dataValue">The data object for which to create a <see cref="ContextMenuStrip"/>.</param> /// <param name="treeViewControl">The <see cref="TreeViewControl"/> to use while executing the <see cref="ContextMenuStrip"/> actions.</param> /// <exception cref="ContextMenuBuilderException">Thrown when any input argument is <c>null</c>.</exception> public ContextMenuBuilder(IApplicationFeatureCommands featureCommandHandler, IImportCommandHandler importCommandHandler, IExportCommandHandler exportCommandHandler, IUpdateCommandHandler updateCommandHandler, IViewCommands viewCommands, object dataValue, TreeViewControl treeViewControl) { try { guiItemsFactory = new GuiContextMenuItemFactory(featureCommandHandler, importCommandHandler, exportCommandHandler, updateCommandHandler, viewCommands, dataValue); treeViewItemsFactory = new TreeViewContextMenuItemFactory(dataValue, treeViewControl); } catch (ArgumentNullException e) { throw new ContextMenuBuilderException(Resources.ContextMenuBuilder_ContextMenuBuilder_Cannot_create_instances_of_factories, e); } contextMenu = new ContextMenuStrip(); }
/// <summary> /// Creates a new instance of <see cref="GuiContextMenuItemFactory"/>. /// </summary> /// <param name="applicationFeatureCommandHandler">The <see cref="IApplicationFeatureCommands"/> /// which contains information for creating the <see cref="ToolStripItem"/>.</param> /// <param name="importCommandHandler">The <see cref="IImportCommandHandler"/> which contains /// information for creating the <see cref="ToolStripItem"/>.</param> /// <param name="exportCommandHandler">The <see cref="IExportCommandHandler"/> which contains /// information for creating the <see cref="ToolStripItem"/>.</param> /// <param name="updateCommandHandler">The <see cref="IUpdateCommandHandler"/> which contains /// information for creating the <see cref="ToolStripItem"/>.</param> /// <param name="viewCommandsHandler">The <see cref="IViewCommands"/> which contains information for /// creating the <see cref="ToolStripItem"/>.</param> /// <param name="dataObject">The data object for which to create <see cref="ToolStripItem"/>.</param> /// <exception cref="ArgumentNullException">Thrown when any input argument is <c>null</c>.</exception> public GuiContextMenuItemFactory(IApplicationFeatureCommands applicationFeatureCommandHandler, IImportCommandHandler importCommandHandler, IExportCommandHandler exportCommandHandler, IUpdateCommandHandler updateCommandHandler, IViewCommands viewCommandsHandler, object dataObject) { if (applicationFeatureCommandHandler == null) { throw new ArgumentNullException(nameof(applicationFeatureCommandHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_gui); } if (importCommandHandler == null) { throw new ArgumentNullException(nameof(importCommandHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_import_handler); } if (exportCommandHandler == null) { throw new ArgumentNullException(nameof(exportCommandHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_export_handler); } if (updateCommandHandler == null) { throw new ArgumentNullException(nameof(updateCommandHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_update_handler); } if (viewCommandsHandler == null) { throw new ArgumentNullException(nameof(viewCommandsHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_view_commands); } if (dataObject == null) { throw new ArgumentNullException(nameof(dataObject), Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_data); } this.applicationFeatureCommandHandler = applicationFeatureCommandHandler; this.importCommandHandler = importCommandHandler; this.exportCommandHandler = exportCommandHandler; this.updateCommandHandler = updateCommandHandler; viewCommands = viewCommandsHandler; this.dataObject = dataObject; }