/// <summary> /// Scan assembly for all classes that derive from class Command. /// </summary> /// <param name="commandTarget">The target the commands operate on.</param> /// <param name="csUnitCtrl">The CsUnitControl the commands operate on.</param> private static void FindCommandsFor(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) { List <Assembly> assembliesToBeSearched = CreateListOfAssembliesToBeSearched(commandTarget); foreach (Assembly a in assembliesToBeSearched) { foreach (Type t in a.GetTypes()) { if (t.IsSubclassOf(typeof(Command)) && !t.IsAbstract) { ConstructorInfo ci = t.GetConstructor(new[] { typeof(ICommandTarget), typeof(CsUnitControl) }); try { Commands.Add((Command)ci.Invoke(new object[] { commandTarget, csUnitCtrl })); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Invocation exception occured while constructing command: " + t); System.Diagnostics.Debug.WriteLine(ex.ToString()); } } } } }
public SaveResultsAsXmlCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&File", "Save Result As &XML...", _menuPosition, true) { _results = new DefaultXmlWriter(RecipeFactory.Current, string.Empty); RecipeFactory.Loaded += RecipeFactory_Loaded; Enabled = false; }
public ViewToolBarCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&View", "&Tool Bar", _menuPosition) { ConfigCurrentUser config = new ConfigCurrentUser(); CommandTarget.ToolBarVisible = config.ToolBarVisible; Checked = config.ToolBarVisible; }
public TestAbortCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Test", "&Abort", _menuPosition, true) { _onRecipeStarted = OnRecipeStarted; _onRecipeFinishedOrAborted = OnRecipeFinishedOrAborted; RecipeFactory.Loaded += this.OnRecipeLoaded; RecipeFactory.Closing += OnRecipeClosing; HookupRecipe(); Enabled = false; }
public RecentRecipesCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&File", "Recent Recipes", RequestedMenuPosition, true) { _onRecipeLoaded = OnRecipeLoaded; _onRecipeSaved = OnRecipeSaved; _recentRecipies = new RecentRecipies(commandTarget); _recentRecipies.AddRecipe(RecipeFactory.Current.PathName); RecipeFactory.Loaded += _onRecipeLoaded; RecipeFactory.Current.Saved += _onRecipeSaved; }
public TestRunCheckedCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Test", "Run Checked", MenuPosition) { Enabled = false; _onRecipeLoaded += OnRecipeLoaded; _onRecipeClosing += OnRecipeClosing; _onRecipeStartedOrFinished += OnRecipeStartedOrFinished; CsUnitControl.CheckedItems.CollectionChanged += OnCheckedItemsChanged; RecipeFactory.Loaded += _onRecipeLoaded; RecipeFactory.Closing += _onRecipeClosing; HookupRecipe(); }
/// <summary> /// Constructs a Command object. As Command is abstract only derived /// non-abstract classes can be instantiated. They internally should /// either call this constructor or the overloaded version which does not /// require the <code>insertLeadingSeparator</code> parameter. /// <param name="commandTarget">The commandTarget this command acts upon.</param> /// <param name="menuName">The name of the menu to which the item is /// added.</param> /// <param name="menuItemName">The name of the menu item.</param> /// <param name="position">The position where to add the menu item.</param> /// <param name="insertLeadingSeparator">If 'true' a separator will be added just /// before the menu item.</param> /// <remarks>The 'position' parameter is only the requested position. If /// a different command requests the same position then the implementation /// of the reflection functionality determines the actual order of the /// commands.</remarks> protected Command(ICommandTarget commandTarget, CsUnitControl csUnitCtrl, string menuName, string menuItemName, int position, bool insertLeadingSeparator) { _commandTarget = commandTarget; _csUnitCtrl = csUnitCtrl; _menuItemName = menuItemName; _menuName = menuName; _desiredMenuPosition = position; _insertLeadingSeparator = insertLeadingSeparator; CreateCommandFullName(menuName, menuItemName); }
public TestRunAllCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Test", "&Run All", MenuPosition, true) { _onRecipeLoaded = OnRecipeLoaded; _onRecipeClosing = OnRecipeClosing; _onOtherRecipeEvent = OnOtherRecipeEvent; _onAssemblyEvent = OnAssemblyEvent; RecipeFactory.Loaded += _onRecipeLoaded; RecipeFactory.Closing += _onRecipeClosing; HookupRecipe(); UpdateEnabledStatus(); }
private const int DesiredToolBarPosition = NoMenuEntry; // Context menu item only public TestRunThisCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Test", "Run This", MenuPosition) { Enabled = false; _onRecipeFinished += OnRecipeFinished; _onRecipeLoaded += OnRecipeLoaded; _onRecipeClosing += OnRecipeClosing; CsUnitControl.SelectedItems.CollectionChanged += SelectedItemsChanged; RecipeFactory.Loaded += _onRecipeLoaded; RecipeFactory.Closing += _onRecipeClosing; HookupRecipe(); }
public RecentAssembliesCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Assembly", "Recent Assemblies", DesiredMenuPosition) { _onRecipeLoaded = OnRecipeLoaded; _onRecipeClosing = OnRecipeClosing; _onAssemblyAdded = OnAssemblyAdded; _recentAssemblies = new RecentAssemblies(); RecipeFactory.Loaded += _onRecipeLoaded; RecipeFactory.Closing += _onRecipeClosing; RecipeFactory.Current.AssemblyAdded += _onAssemblyAdded; }
public TestRunFailedCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Test", "Run &Failed", _menuPosition, true) { Enabled = ! _failedTestCriterion.IsEmpty; _onRecipeLoaded = OnRecipeLoaded; _onRecipeClosing = OnRecipeClosing; _onTestErrorOrFail = OnTestErrorOrFail; _onAssemblyAdded = OnAssemblyAdded; _onAssemblyRemoving = OnAssemblyRemoving; RecipeFactory.Loaded += _onRecipeLoaded; RecipeFactory.Closing += _onRecipeClosing; HookupRecipe(); }
public TestRunFailedCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Test", "Run &Failed", _menuPosition, true) { Enabled = !_failedTestCriterion.IsEmpty; _onRecipeLoaded = OnRecipeLoaded; _onRecipeClosing = OnRecipeClosing; _onTestErrorOrFail = OnTestErrorOrFail; _onAssemblyAdded = OnAssemblyAdded; _onAssemblyRemoving = OnAssemblyRemoving; RecipeFactory.Loaded += _onRecipeLoaded; RecipeFactory.Closing += _onRecipeClosing; HookupRecipe(); }
public AboutCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Help", "&About...", _menuPosition, true) { }
public RecipeOpenCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&File", "&Open Recipe...", RequestedMenuPosition) { }
/// <summary> /// Constructs a Command object. As Command is abstract only derived /// non-abstract classes can be instantiated. They internally should /// either call this constructor or the overloaded version which also /// supports the <code>insertLeadingSeparator</code> parameter. /// </summary> /// <param name="commandTarget">The commandTarget this command operates on.</param> /// <param name="csUnitCtrl">The CsUnitControl to operate on.</param> /// <param name="menuName">The name of the menu to which the item is /// added.</param> /// <param name="menuItemName">The name of the menu item.</param> /// <param name="position">The position where to add the menu item.</param> protected Command(ICommandTarget commandTarget, CsUnitControl csUnitCtrl, string menuName, string menuItemName, int position) : this(commandTarget, csUnitCtrl, menuName, menuItemName, position, false) { }
/// <summary> /// Using reflection this static method creates all commands which can be /// found in the assembly in which class csUnit.Runner.Commands.Command is /// defined. /// </summary> /// <remarks>First this method scans the assembly in which class Command is /// defined. In step two, when all commands have been found, the commands /// are then used to fill the menus.</remarks> /// <param name="commandTarget">The commandTarget the command operates /// on.</param> /// <param name="csUnitCtrl">The CsUnitControl the command operates on. /// </param> public static void CreateCommands(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) { FindCommandsFor(commandTarget, csUnitCtrl); FillMainMenuStrip(commandTarget.MainMenuStrip); }
public ShowFindPanelCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&View", "&Find Panel", _menuPosition, true) { CsUnitControl.FindPanel.Visible = false; }
/// <summary> /// Instantiates the command. /// </summary> /// <param name="commandTarget">The form to act upon.</param> /// <param name="csUnitCtrl">The control on which to operate</param> public RecipeSaveAsCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&File", "Save Recipe &As...", DesiredMenuPosition) { }
public FileExitCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&File", "E&xit", _menuPosition, true) { }
public GotoOnlineDocumentationCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Help", "Online &Documentation", _menuPosition) { }
public ReportBugCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Help", "Report a Bug", _menuPosition) { }
public ViewOptionsCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&View", "&Options...", _menuPosition, true) { }
/// <summary> /// Scan assembly for all classes that derive from class Command. /// </summary> /// <param name="commandTarget">The target the commands operate on.</param> /// <param name="csUnitCtrl">The CsUnitControl the commands operate on.</param> private static void FindCommandsFor(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) { List<Assembly> assembliesToBeSearched = CreateListOfAssembliesToBeSearched(commandTarget); foreach( Assembly a in assembliesToBeSearched ) { foreach( Type t in a.GetTypes() ) { if( t.IsSubclassOf(typeof(Command)) && !t.IsAbstract ) { ConstructorInfo ci = t.GetConstructor(new[] { typeof(ICommandTarget), typeof(CsUnitControl) }); try { Commands.Add((Command) ci.Invoke(new object[] { commandTarget, csUnitCtrl })); } catch( Exception ex ) { System.Diagnostics.Debug.WriteLine("Invocation exception occured while constructing command: " + t); System.Diagnostics.Debug.WriteLine(ex.ToString()); } } } } }
public AssemblyRemoveCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Assembly", "&Remove", MenuPosition, true) { Enabled = false; CsUnitControl.SelectedItems.CollectionChanged += SelectedItemsCollectionChanged; }
public CheckForUpdatesCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Help", "Chec&k for Updates", _menuPosition, true) { }
public AssemblyReloadCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Assembly", "R&eload", MenuPosition) { Enabled = false; CsUnitControl.SelectedItems.CollectionChanged += OnSelectedItemsChanged; }
public RecipeSaveCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&File", "&Save Recipe", _menuPosition) { }
public AssemblyAddCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl) : base(commandTarget, csUnitCtrl, "&Assembly", "&Add...", DesiredMenuPosition, true) { }