public GitToolCommand(string name, string Command, CommandScope scope = CommandScope.Project, bool saveOnExecution = false) { this.Name = name; this.Command = Command; Scope = scope; SaveOnExecution = saveOnExecution; }
public ApplyMetadataCommand(string templateKey, string fileId, Dictionary <string, object> metadata, CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) : base(scope, accessLevel) { _templateKey = templateKey; _fileId = fileId; _metadata = metadata; }
public override async Task <TResult> OnCommandAsync <TCommand, TResult>(Func <TCommand, CancellationToken, Task <TResult> > next, TCommand cmd, CancellationToken ct) { var command = (await _commands.AddAsync(new CommandEntity { ExternalId = cmd.Id, Name = typeof(TCommand).Name, Payload = JsonSerializer.Serialize(cmd), Result = null, CreatedOn = cmd.CreatedOn, CreatedBy = cmd.CreatedBy, ExecutionTime = TimeSpan.Zero }, ct)).Entity; TResult result; using (CommandScope.Begin(command.ExternalId, command.Id)) { result = await next(cmd, ct); } command.Result = result == null ? null : JsonSerializer.Serialize(result); command.ExecutionTime = DateTimeOffset.UtcNow - cmd.CreatedOn; return(result); }
public static async Task <BoxFile> CreateSmallFile(string parentId = "0", CommandScope commandScope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) { var createFileCommand = new CreateFileCommand(GetUniqueName("file"), GetSmallFilePath(), parentId, commandScope, accessLevel); await ExecuteCommand(createFileCommand); return(createFileCommand.File); }
public static async Task <BoxFolder> CreateFolder(string parentId = "0", CommandScope commandScope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) { var createFolderCommand = new CreateFolderCommand(GetUniqueName("folder"), parentId, commandScope, accessLevel); await ExecuteCommand(createFolderCommand); return(createFolderCommand.Folder); }
public static async Task <BoxMetadataTemplate> CreateMetadataTemplate(Dictionary <string, object> metadata = null, CommandScope commandScope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) { var createMetadataTemplateCommand = new CreateMetadataTemplateCommand(GetUniqueName("template_key", false), ToStringMetadataFields(metadata), commandScope, accessLevel); await ExecuteCommand(createMetadataTemplateCommand); return(createMetadataTemplateCommand.MetadataTemplate); }
public static TCommand Execute <TCommand>(params object[] args) where TCommand : MonoCommand, new() { GameObject mgGameObject = MonoSingleton.GetMGGameObject(); object[] attibutes = typeof(TCommand).GetCustomAttributes(true); bool oneItemOnScene = false; CommandScope scope = CommandScope.Application; foreach (Attribute eachAttribute in attibutes) { if (eachAttribute is SingletoneAttribute) { oneItemOnScene = true; } else if (eachAttribute is MonoCommandScopeAttribute) { MonoCommandScopeAttribute monoCommandScopeAttribute = (MonoCommandScopeAttribute)eachAttribute; scope = monoCommandScopeAttribute.IsApplication ? CommandScope.Application : CommandScope.Scene; } } if (oneItemOnScene) { TCommand command = (TCommand)UnityEngine.Object.FindObjectOfType(typeof(TCommand)); if (command != null) { MonoLog.Log(MonoLogChannel.Core, "Found existing command " + command); return(command); } } GameObject target = null; if (scope == CommandScope.Application) { target = new GameObject(typeof(TCommand).Name); target.transform.parent = mgGameObject.transform; UnityEngine.Object.DontDestroyOnLoad(target); } else { target = UIManager.CurrentSceneController.gameObject; } TCommand result = ExecuteOn <TCommand>(target, args); result.Scope = scope; return(result); }
public ActionConfiguration(Trigger trigger, string glob, string workingDirectory, string command, string solutionRoot, string projectRoot, CommandScope scope) { this.Trigger = trigger; this.Glob = glob; this.RelativeWorkingDirectory = workingDirectory; this.Command = command; this.SolutionRoot = solutionRoot; this.ProjectRoot = projectRoot; this.Scope = scope; }
public static async Task <Tuple <BoxFile, string> > CreateSmallFileWithMetadata (string parentId = "0", Dictionary <string, object> metadata = null, CommandScope commandScope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) { var createFileCommand = new CreateFileCommand(GetUniqueName("file"), GetSmallFilePath(), parentId, commandScope, accessLevel); await ExecuteCommand(createFileCommand); var createMetadataTemplateCommand = new CreateMetadataTemplateCommand(GetUniqueName("template_key", false), ToStringMetadataFields(metadata), commandScope, accessLevel); await ExecuteCommand(createMetadataTemplateCommand); var applyMetadataCommand = new ApplyMetadataCommand(createMetadataTemplateCommand.TemplateKey, createFileCommand.FileId, metadata, commandScope, accessLevel); await ExecuteCommand(applyMetadataCommand); return(Tuple.Create(createFileCommand.File, createMetadataTemplateCommand.TemplateKey)); }
private int GetCommandKey(SlackBotCommand command) { int commandId = CommandTypeRegistry.GetCommandId(command.Name); CommandScope scope = CommandTypeRegistry.GetCommandType(command.Name).GetCommandScope(); object preKey = null; switch (scope) { case CommandScope.Global: preKey = commandId; break; case CommandScope.Channel: preKey = new Tuple <int, string>(commandId, command.Channel.id); break; case CommandScope.User: preKey = new Tuple <int, string, string>(commandId, command.Channel.id, command.User.id); break; } return(preKey.GetHashCode()); }
/// <summary> /// A commandlet represents the abstract idea of the typical IRC command represented with a start-character (!) and a string for identify. All the parsing will be done /// by the bot, you only get exactly the events you registered to. For example: you can register an event which is only thrown if used in a private message by certain users, /// or in a certain channel. /// </summary> /// <param name="command">the command string including initial charakter. like "!example" </param> /// <param name="helptext">A help for this certain command which should be displayed by the !help command</param> /// <param name="handler">The name of the method which should be called, can be private</param> /// <param name="owner">this (the class where this command is provided)</param> /// <param name="scope">Should the event be fired by Channelmessages or Privatemessages or Both</param> /// <param name="accessString">globally unique string which identifies a restricted function, something like: plugin_function, can be done manually too, via bot.acl.*</param> /// <param name="channelList">Only usefull if the Scope is Public! The Handler will only be called if the request was made in a certain channel. No restriction == null</param> public Commandlet(string command, string helptext, EventHandler<IrcEventArgs> handler, object owner, CommandScope scope = CommandScope.Both, string accessString = null, List<string> channelList = null) { Command = command; HelpText = helptext; if (owner is AbstractPlugin) { var plugin = owner as AbstractPlugin; Handler = null; HandlerName = handler.Method.Name; Owner = plugin.FullName; SourcePlugin = plugin.FullName; } else { Handler = handler; Owner = owner; SourcePlugin = "Core"; } Scope = scope; AccessString = accessString; this.channelList = channelList; }
/// <summary> /// A commandlet represents the abstract idea of the typical IRC command represented with a start-character (!) and a string for identify. All the parsing will be done /// by the bot, you only get exactly the events you registered to. For example: you can register an event which is only thrown if used in a private message by certain users, /// or in a certain channel. /// </summary> /// <param name="command">the command string including initial charakter. like "!example" </param> /// <param name="helptext">A help for this certain command which should be displayed by the !help command</param> /// <param name="handler">The name of the method which should be called, can be private</param> /// <param name="owner">this (the class where this command is provided)</param> /// <param name="scope">Should the event be fired by Channelmessages or Privatemessages or Both</param> /// <param name="accessString">globally unique string which identifies a restricted function, something like: plugin_function, can be done manually too, via bot.acl.*</param> /// <param name="channelList">Only usefull if the Scope is Public! The Handler will only be called if the request was made in a certain channel. No restriction == null</param> public Commandlet(string command, string helptext, EventHandler <IrcEventArgs> handler, object owner, CommandScope scope = CommandScope.Both, string accessString = null, List <string> channelList = null) { Command = command; HelpText = helptext; if (owner is AbstractPlugin) { var plugin = owner as AbstractPlugin; Handler = null; HandlerName = handler.Method.Name; Owner = plugin.FullName; SourcePlugin = plugin.FullName; } else { Handler = handler; Owner = owner; SourcePlugin = "Core"; } Scope = scope; AccessString = accessString; this.channelList = channelList; }
private static void Main(string[] args) { // context initialization if necessary var context = new CommandContext { Context = new Dictionary <string, object> { ["team"] = new List <string>() } }; // init command executor var runner = new CommandRunner(context); // init command/transaction scope using (var scope = new CommandScope()) { scope.Init() .Add(new AddShipCommand("Black Cuttlefish")) .Add(new AddTeamCommand("John Silver")) .Add(new AddTeamCommand("Capitan Smollet")) .Add(new AddTeamCommand("Doctor Livcy")) .Add(new AddTeamCommand("Billi Bonc")) .Add(new AddTeamCommand("Jim")) .Add(new AddRegattaCommand(Guid.NewGuid().ToString())) .Add(new FailureCommand()) .Run(runner) // with fluent, we can do something like this .Init() .Add(new AddTeamCommand("Billi Bonc")) .Add(new AddTeamCommand("Jim")) .Add(new AddRegattaCommand(Guid.NewGuid().ToString())) .Add(new FailureCommand()) .Run(runner); } }
public GitToolCommand(string name, string Command, CommandScope scope = CommandScope.Project) { this.Name = name; this.Command = Command; Scope = scope; }
public ActionConfigurationBuilder WithScope(CommandScope scope) { this.scope = scope; return this; }
public static async Task <BoxRetentionPolicy> CreateRetentionPolicy(string folderId = "0", CommandScope commandScope = CommandScope.Test) { var createRetentionPolicyCommand = new CreateRetentionPolicyCommand(folderId, GetUniqueName("policy"), commandScope); await ExecuteCommand(createRetentionPolicyCommand); return(createRetentionPolicyCommand.Policy); }
public CreateWebLinkCommand(string name, string parentFolderId, CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) : base(scope, accessLevel) { _name = name; _parentFolderId = parentFolderId; }
public void Should_be_able_to_parse_valid_command_scope(string configValue, CommandScope parsedValue) { var input = this.CreateConfig(config => config.WithAction(action => action.WithScope(configValue))); var configuration = this.Parser.Parse("", "", input).Single(); Assert.That(configuration.Scope, Is.EqualTo(parsedValue)); }
public CreateMetadataTemplateCommand(string templateKey, List <BoxMetadataTemplateField> metadataFields, CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) : base(scope, accessLevel) { TemplateKey = templateKey; _metadataFields = metadataFields; }
public CreateFolderCommand(string folderName, string parentId = "0", CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) : base(scope, accessLevel) { _folderName = folderName; _parentId = parentId; }
public CommandBase(CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) { Scope = scope; AccessLevel = accessLevel; }
public CreateFileCommand(string fileName, string filePath, string folderId = "0", CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) : base(scope, accessLevel) { _fileName = fileName; _filePath = filePath; _folderId = folderId; }
public void iDetach(CommandReceiver commandScope) { m_Owner = null; }
//public ICommandListenerLinked<CommandReciver> m_ParentValidator; ////////////////////////////////////////////////////////////////////////// public void iAttach(CommandReceiver commandScope) { m_Owner = commandScope as CommandScope; }
public AddCollaborationExemptCommand(string userId, CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) : base(scope, accessLevel) { _userId = userId; }
public CreateRetentionPolicyCommand(string folderId, string policyName, CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) : base(scope, accessLevel) { _policyName = policyName; _folderId = folderId; }
public CreateEnterpriseUserCommand(string name, string externalAppUserId, CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) : base(scope, accessLevel) { _name = name; _externalAppUserId = externalAppUserId; }
public DeleteFileCommand(string fileId, CommandScope scope = CommandScope.Test) : base(scope) { _fileId = fileId; }
public DeleteFolderCommand(string folderId, CommandScope scope = CommandScope.Test) : base(scope) { _folderId = folderId; }