/////////////////////////////////////////////////////////////////// #region Private Static Methods private static EnsembleDictionary CreateSubCommands() { EnsembleDictionary subCommands = new EnsembleDictionary(); subCommands.Add("example3", null); return(subCommands); }
/////////////////////////////////////////////////////////////////// #region Private Static Methods private static EnsembleDictionary CreateSubCommands() { EnsembleDictionary subCommands = new EnsembleDictionary(); subCommands.Add("about", null); subCommands.Add("isolated", null); subCommands.Add("options", null); return(subCommands); }
/////////////////////////////////////////////////////////////////////// private void SetupSubCommands( ICommandData commandData, IEnsembleData ensembleData ) { // // NOTE: Get the IExecute configured to handle the sub-commands // for this ensemble. // IExecute execute = this.SubCommandExecute; if (execute == null) { if (ensembleData != null) { execute = ensembleData.SubCommandExecute; } else { ISubCommandData subCommandData = null; if (commandData != null) { subCommandData = new SubCommandData( commandData.Name, commandData.Group, commandData.Description, commandData.ClientData, commandData.TypeName, commandData.Flags, SubCommandFlags.None, this, commandData.Token); } execute = new SubCommand(subCommandData, this.Plugin); } // // NOTE: Set the IExecute that we either obtained from the // passed IEnsembleData -OR- the one that we created // ourselves. // this.SubCommandExecute = execute; } EnsembleDictionary subCommands = this.SubCommands; if (subCommands == null) { subCommands = new EnsembleDictionary(); subCommands["about"] = execute as ISubCommand; subCommands["isolated"] = execute as ISubCommand; subCommands["options"] = execute as ISubCommand; this.SubCommands = subCommands; } }
/////////////////////////////////////////////////////////////////////// public virtual ReturnCode AddOrUpdateSubCommand( string name, ISubCommand subCommand, IClientData clientData, SubCommandFlags flags, ref Result error ) { if (name == null) { error = "invalid sub-command name"; return(ReturnCode.Error); } EnsembleDictionary subCommands = this.SubCommands; if (subCommands == null) { error = "sub-commands not available"; return(ReturnCode.Error); } if ((subCommand == null) && FlagOps.HasFlags(flags, SubCommandFlags.Core, true)) { subCommand = GetCoreSubCommand(); } subCommands[name] = subCommand; if (subCommand != null) { EnsembleDictionary subSubCommands = subCommand.SubCommands; if (subSubCommands != null) { subSubCommands[name] = subCommand; } } return(ReturnCode.Ok); }