public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is Join) { if (!user.Invited.Contains(channel)) { user.IrcDaemon.Replies.SendInviteOnlyChannel(user, channel); return false; } user.Invited.Remove(channel); } if (command is Invite) { UserPerChannelInfo upci; if (channel.UserPerChannelInfos.TryGetValue(user.Nick, out upci)) { if (upci.Modes.Level < 30) { channel.IrcDaemon.Replies.SendChannelOpPrivilegesNeeded(user, channel); return false; } } else { channel.IrcDaemon.Replies.SendNotOnChannel(user, channel.Name); return false; } } return true; }
public bool OnInfoCommand( CommandBase.CommandData cmdData ) { if( EngineCmdExecuterProxy != null ) return EngineCmdExecuterProxy.OnInfoCommand( cmdData ); return true; }
public void RegisterCommand(string commandName, CommandBase command) { if (commandName.IndexOf('.') >= 0) throw new ArgumentException("Command name cannot contain dot symbol.", "commandName"); if (!_commands.ContainsKey(commandName)) _commands.Add(commandName, command); }
public UsuarioViewModel() { if (IsInDesignMode) return;//por si acaso ? _ServicioUsuario = new UsuarioServiceClient(); _ServicioDepartamento = new DepartamentoServiceClient(); _ServicioProyecto = new ProyectoServiceClient(); ListaUsuarios = new ObservableCollection<usuarioDTO>(); ItemUsuario = new usuarioDTO(); NuevoUsuarioCommand = new CommandBase(p => true, p => NuevoUsuarioCommandAccion()) { IsEnable = true }; GuardarUsuarioCommand = new CommandBase(p => true, p => GuardarUsuarioCommandAccion()) { IsEnable = true }; EliminarUsuarioCommand = new CommandBase(p => true, p => EliminarUsuarioCommandAccion()) { IsEnable = true }; NuevoProyectoCommand = new CommandBase(p => true, p => NuevoProyectoCommandAccion()) { IsEnable = true }; AgregarProyectoCommand = new CommandBase(p => true, p => AgregarProyectoCommandAccion()) { IsEnable = true }; EliminarProyectoCommand = new CommandBase(p => true, p => EliminarProyectoCommandAccion()) { IsEnable = true }; ListarUsuariosCommand = new CommandBase(p => true, p => ListarUsuariosCommandAction()) { IsEnable = true }; ListarUsuariosXNombreCommand = new CommandBase(p => true, p => ListarUsuariosXNombreCommandCommandAccion()) { IsEnable = true }; //lista los usuarios busqueda rapida _ServicioUsuario.ListarUsuariosAsync(); _ServicioUsuario.ListarUsuariosCompleted += _ServicioUsuario_ListarUsuariosCompletedBusquedaRapida; //lista los departamentos _ServicioDepartamento.ListarDepartamentosAsync(); _ServicioDepartamento.ListarDepartamentosCompleted += _ServicioDepartamento_ListarDepartamentosCompleted; ListarUsuariosCommandAction(); }
private ExecutionResult Save(CommandBase command) { var user = ((SaveUserCommand)command).UserDto; //Validate(user); user.Id = Guid.NewGuid().ToString(); var id = UserDao.Save(user); return new ExecutionResult { Data = UserDao.Get(id) }; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is List) { // TODO } return true; }
/// <summary> /// 构造函数,默认成功 /// </summary> /// <param name="client">通讯的Socket/UdpClient/SerailPort</param> /// <param name="param">通讯参数,IP地址或串口参数</param> /// <param name="cmds">当前进行通讯的指令列表</param> /// <param name="response">响应结果</param> public ResponseEventArgs(object client, CommiTarget param, CommandBase[] cmds, byte[] response) { this.Client = client; this.Commands = cmds; this.Response = response; this.ContentLen = response.Length; this.Target = param; }
/// <summary> /// Инициализирует экземпляр класса <see cref="AsyncCommand"/> и /// задает команду <paramref name="command"/>, которая будет провалидирована и /// выполнена асинхронно. /// </summary> /// <param name="command"></param> public AsyncCommand(CommandBase command) { if (command == null) { throw new ArgumentNullException("command"); } Command = command; }
public bool SetConfigOption( CommandBase.CommandData commandData ) { bool bRet = false; if( commandData.StrCmd == "id" ) { CommandBase.CommandData subCmdData = commandData.QueueSubCmdData.Peek(); if( subCmdData != null && subCmdData.StrCmd == "name" ) { Name = subCmdData.QueueStrValue.Peek(); bRet = true; } else if( subCmdData != null && subCmdData.StrCmd == "author" ) { Authur = subCmdData.QueueStrValue.Peek(); bRet = true; } } else if( commandData.StrCmd == "option" ) { ChessEngineOption option = new ChessEngineOption(); foreach( CommandBase.CommandData subCmdData in commandData.QueueSubCmdData ) { if( subCmdData != null ) { if( subCmdData.StrCmd == "name" ) { option.Name = subCmdData.QueueStrValue.Peek(); } else if( subCmdData.StrCmd == "type" ) { option.Type = subCmdData.QueueStrValue.Peek(); } else if( subCmdData.StrCmd == "default" ) { option.Default = subCmdData.QueueStrValue.Peek(); } else if( subCmdData.StrCmd == "min" ) { option.Min = subCmdData.QueueStrValue.Peek(); } else if( subCmdData.StrCmd == "max" ) { option.Max = subCmdData.QueueStrValue.Peek(); } else if( subCmdData.StrCmd == "var" ) { foreach( string strCurrVar in subCmdData.QueueStrValue ) option.queueVar.Enqueue( strCurrVar ); } } } AddOption( option ); bRet = true; } return bRet; }
public MainWindowModel(MainWindow v) { this.view = v; _FindPathCommand = new CommandBase(FindPath); _FindBadFilesCommand = new CommandBase(this.FindBadFiles, this.FindBadFilesCanExecute); _ExecuteFileRenameCommand = new CommandBase(this.ExecuteFileRename, this.ExecuteFileRenameCanExecute); _CancelActionCommand = new CommandBase(this.CancelAction, this.CancelActionCanExecute); this.Pattern = ConfigurationManager.AppSettings["DefaultPattern"]; }
public static CommandBase add_MenuItem(this O2_VS_AddIn o2AddIn, string buttonText, string targetMenu, Action onExecute) { var newCommand = new CommandBase(o2AddIn) { ButtonText = buttonText, TargetMenu = targetMenu, Execute = onExecute }; newCommand.create(); return newCommand; }
// on Process Engine command public bool OnInitStockfishCommand( CommandBase.CommandData cmdData ) { // why can't i send first command???????? // 엔진에서 첫번째 명령 스트링을 초기화 안해서.... ChessEngineManager.Instance.Send( "\n" ); ChessEngineManager.Instance.Send( "uci" ); if( EngineCmdExecuterProxy != null ) return EngineCmdExecuterProxy.OnInitStockfishCommand( cmdData ); return true; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is PrivateMessage || command is Notice) { if (!channel.UserPerChannelInfos.ContainsKey(user.Nick)) { user.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name); return false; } } return true; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is PrivateMessage || command is Notice) { UserPerChannelInfo upci; if (!channel.UserPerChannelInfos.TryGetValue(user.Nick, out upci) || upci.Modes.Level < 10) { user.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name); return false; } } return true; }
/// <summary> /// Adds a command to the manager. /// </summary> /// <param name="command">Reference to the command to add</param> public void Add(CommandBase command) { Commands2 vsCommands = (Commands2)dte.Commands; // Get full name how Visual Studio queries this command string fullname = vsCommands.GetFullname(addIn, command.Name); // Add to our own VsTortoise command management commands[fullname] = command; // Create the command inside Visual Studio permanently Command vsCommand = vsCommands.CreateCommandButton(addIn, command); }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is Join) { if (_limit <= channel.UserPerChannelInfos.Count) { user.IrcDaemon.Replies.SendChannelIsFull(user, channel); return false; } } return true; }
public void Send(CommandBase command) { var handlers = this.GetCommandActions(command.GetType()).ToList(); if (handlers.Any()) { if (handlers.Count() != 1) throw new InvalidOperationException("cannot send to more than one handler"); handlers.First().AsDynamic().Handle(command); ((IDisposable)handlers.First()).Dispose(); } else { throw new InvalidOperationException("no handler registered"); } }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is Join) { var keys = args.Count > 1 ? (IEnumerable<string>)CommandBase.GetSubArgument(args[1]) : new List<string>(); if (keys.All(k => k != _key)) { user.IrcDaemon.Replies.SendBadChannelKey(user, channel); return false; } } return true; }
public void ExecuteCommand(CommandBase command) { this.undoStack.Push(command); try { command.Execute(); } catch (Exception e) { this.undoStack.Pop(); if (this.ExceptionManager != null) { this.ExceptionManager.HandleException(e); } } }
bool ExcuteBestMoveCommand( CommandBase.CommandData cmdData ) { // best move string to rank/pile string strBestMove = cmdData.QueueStrValue.Peek(); //UnityEngine.Debug.LogError( "ExcuteBestMoveCommand() - best move string = " + strBestMove ); string strSrcPos = strBestMove.Substring(0, 2); string strTrgPos = strBestMove.Substring(2, 2); int nSrcRank, nSrcPile; ChessData.GetStringToRankPile( strSrcPos, out nSrcRank, out nSrcPile ); if( ChessPosition.IsInvalidPositionIndex(nSrcRank, nSrcPile) ) { UnityEngine.Debug.LogError( "ExcuteBestMoveCommand() - Invalid src rank, pile" ); return false; } int nTrgRank, nTrgPile; ChessData.GetStringToRankPile( strTrgPos, out nTrgRank, out nTrgPile ); if( ChessPosition.IsInvalidPositionIndex(nTrgRank, nTrgPile) ) { UnityEngine.Debug.LogError( "ExcuteBestMoveCommand() - Invalid src rank, pile" ); return false; } ChessBoardSquare srcSquare, trgSquare; srcSquare = board.aBoardSquare[nSrcPile, nSrcRank]; trgSquare = board.aBoardSquare[nTrgPile, nTrgRank]; //UnityEngine.Debug.LogError( "ExcuteBestMoveCommand() - src rank, pile " + nSrcRank + " , " + nSrcPile ); //UnityEngine.Debug.LogError( "ExcuteBestMoveCommand() - trg rank, pile " + nTrgRank + " , " + nTrgPile ); if( board.AIMoveTo( srcSquare, trgSquare ) ) { // turn board.CurrTurn = ChessData.GetOppositeSide( board.CurrTurn ); // invalidate ready state board.Ready = true; return true; } UnityEngine.Debug.LogError( "ExcuteBestMoveCommand() - Invalid src rank, pile" ); return false; }
public void AddCommand(CommandBase command, Action<ResultBase> onResult, TimeSpan sendCommandWithin, TimeSpan expectResultWithin) { lock (this) { if (_state != State.Empty) throw new InvalidOperationException("Command cannot be set - currently in state " + _state); _currentCommand = command; _resultCallback = onResult; _timeCommandAdded = DateTime.UtcNow; _timeCommandSent = DateTime.MinValue; _commandAvailableEvent.Set(); _timeAllowedForSend = sendCommandWithin; _timeAllowedForResult = expectResultWithin; _state = State.CommandQueued; } }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is PrivateMessage || command is Notice) { if (args[1].Any(c => c == IrcConstants.IrcColor)) { channel.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name, "Color is not permitted in this channel"); return false; } if (args[1].Any(c => c == IrcConstants.IrcBold || c == IrcConstants.IrcNormal || c == IrcConstants.IrcUnderline || c == IrcConstants.IrcReverse)) { channel.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name, "Control codes (bold/underline/reverse) are not permitted in this channel"); return false; } } return true; }
public bool OnOptionCommand( CommandBase.CommandData cmdData ) { // enable/disable ui engine option // setting default option ChessEngineOption option = ChessEngineManager.Instance.DefaultConfigData.GetConfigOption( cmdData.GetSubCommandValue("name") ); if( option != null ) { OffGameUI offGameUIScript = GUIManager.Instance.GetUIHouseScript<OffGameUI>( "OffGameUI" ); offGameUIScript.optionScrollPanelScript.SetOption( option ); return true; } if( EngineCmdExecuterProxy != null ) return EngineCmdExecuterProxy.OnOptionCommand( cmdData ); return false; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is Topic) { UserPerChannelInfo upci; if (!channel.UserPerChannelInfos.TryGetValue(user.Nick, out upci)) { user.IrcDaemon.Replies.SendNotOnChannel(user, channel.Name); return false; } if (upci.Modes.Level < 30) { user.IrcDaemon.Replies.SendChannelOpPrivilegesNeeded(user, channel); return false; } } return true; }
public void RegisterCommand(string name, bool doBindings, CommandBase commandHandler, bool onlyToolbar) { Command command = RegisterCommandPrivate(name, commandHandler, onlyToolbar); if(doBindings) { try { commandHandler.BindToKeyboard(command); } catch(ArgumentException e) { Log.Error("Failed to register keybindings for {0}: {1}", name, e.ToString()); } } mCommands.Add(name, commandHandler); }
public void Enqueue(CommandBase asyncCommand) { if (asyncCommand == null) { throw new ArgumentNullException("asyncCommand"); } var msg = new Message { Body = asyncCommand, Label = asyncCommand.GetType().FullName, Formatter = _formatter }; using (msg) { _innerQueue.Send(msg); } }
internal override void PerformCommand(CommandBase command) { ArgumentAssert.IsNotNull(command, "command"); Open(); try { if (!SkipHandshake) base.SendHandshake(); if (!SkipSerializeCommand) command.Serialize(DataStream); DataStream.Flush(); if (!SkipDeserializeCommand) command.Deserialize(DataStream); } finally { Close(); } }
public void RegisterCommand(bool doBindings, CommandBase commandHandler, bool onlyToolbar) { OleMenuCommand command = RegisterCommandPrivate(commandHandler, onlyToolbar); if(command != null && doBindings) { try { Command cmd = mPlugin.Commands.Item(commandHandler.CanonicalName, -1); commandHandler.BindToKeyboard(cmd); } catch(ArgumentException e) { Log.Error("Failed to register keybindings for {0}: {1}", commandHandler.CanonicalName, e.ToString()); } } mCommands.Add(commandHandler.CanonicalName, commandHandler); }
private static object[] MakeArray(ConstructorInfo constructorInfo, JObject arguments, CommandBase command) { var parameters = constructorInfo.GetParameters(); List<object> args = new List<object>(); foreach (var parameter in parameters) { if (parameter.ParameterType == command.GetType()) { args.Add(command); continue; } if (arguments[parameter.Name] == null) return null; var token = arguments[parameter.Name]; var arg = token.ToObject(parameter.ParameterType, new CustomSerializerSettings()); args.Add(arg); } return args.ToArray(); }
private Command RegisterCommandPrivate(string name, CommandBase commandHandler, bool toolbarOnly) { Command vscommand = null; try { vscommand = mPlugin.Commands.Item(Absname(name), -1); return vscommand; } catch(System.ArgumentException) { } Log.Info("Registering the command {0} from scratch", name); object[] contextGuids = new object[] { }; int commandStatus = (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled; if(0 == commandHandler.IconIndex) { vscommand = mPlugin.Commands.AddNamedCommand2(mPlugin.AddIn, name, name/*commandHandler.Name*/, commandHandler.Tooltip, true, -1, ref contextGuids, commandStatus, (int)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton); } else { int style = (int)vsCommandStyle.vsCommandStylePictAndText; if(toolbarOnly) { style = (int)vsCommandStyle.vsCommandStylePict; } vscommand = mPlugin.Commands.AddNamedCommand2(mPlugin.AddIn, name, name/*commandHandler.Name*/, commandHandler.Tooltip, false, commandHandler.IconIndex, ref contextGuids, commandStatus, style, vsCommandControlType.vsCommandControlTypeButton); } // Register the graphics controls for this command as well. // First let the command itself have a stab at register whatever it needs. // Then by default we always register ourselves in the main toolbar of the application. if(!commandHandler.RegisterGUI(vscommand, mCommandBar, toolbarOnly)) { } return vscommand; }
/// <summary> /// Performs specified command against this connection. Inetrnal method, called from command. /// </summary> /// <param name="command"></param> internal abstract void PerformCommand(CommandBase command);
public async Task <bool> SendCommand(CommandBase command, int timeout = 2500) { var message = await SendCommand(command, false); return(message?.ResponseMessage?.Equals("success", StringComparison.InvariantCultureIgnoreCase) ?? false); }
public async Task ExecuteCommandAsync(CommandBase command) { Type commandType = command.GetType(); await commandHandlers[commandType].HandleAsync((dynamic)command); }
public TestExplorerCommandMenuItem(CommandBase command) : base(command) { }
public abstract void AddCmd(CommandBase cmd);
public async Task ApplyCommand() { using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { if (ServerStore.IsLeader() == false) { throw new NoLeaderException("Not a leader, cannot accept commands."); } HttpContext.Response.Headers["Reached-Leader"] = "true"; var commandJson = await context.ReadForMemoryAsync(RequestBodyStream(), "external/rachis/command"); CommandBase command; try { command = CommandBase.CreateFrom(commandJson); } catch (InvalidOperationException e) { RequestRouter.AssertClientVersion(HttpContext, e); throw; } switch (command) { case AddOrUpdateCompareExchangeBatchCommand batchCmpExchange: batchCmpExchange.ContextToWriteResult = context; break; case CompareExchangeCommandBase cmpExchange: cmpExchange.ContextToWriteResult = context; break; } var isClusterAdmin = IsClusterAdmin(); command.VerifyCanExecuteCommand(ServerStore, context, isClusterAdmin); var(etag, result) = await ServerStore.Engine.PutAsync(command); HttpContext.Response.StatusCode = (int)HttpStatusCode.OK; var ms = context.CheckoutMemoryStream(); try { using (var writer = new BlittableJsonTextWriter(context, ms)) { context.Write(writer, new DynamicJsonValue { [nameof(ServerStore.PutRaftCommandResult.RaftCommandIndex)] = etag, [nameof(ServerStore.PutRaftCommandResult.Data)] = result }); writer.Flush(); } // now that we know that we properly serialized it ms.Position = 0; await ms.CopyToAsync(ResponseBodyStream()); } finally { context.ReturnMemoryStream(ms); } } }
public override Task OnLoaded() { this.ActionControlContentControl = (ContentControl)this.GetByUid("ActionControlContentControl"); var commandTypeStrings = System.Enum.GetValues(typeof(CommandTypeEnum)) .Cast <CommandTypeEnum>() .Where(v => !EnumHelper.IsObsolete(v) && v != CommandTypeEnum.Game && v != CommandTypeEnum.Remote && v != CommandTypeEnum.Custom) .Select(v => EnumHelper.GetEnumName(v)) .ToList(); commandTypeStrings.Add("SingleAction"); this.CommandTypeComboBox.ItemsSource = commandTypeStrings; var actionTypes = System.Enum.GetValues(typeof(ActionTypeEnum)) .Cast <ActionTypeEnum>() .Where(v => !EnumHelper.IsObsolete(v) && v != ActionTypeEnum.Custom) .OrderBy(v => v); this.SingleActionNameComboBox.ItemsSource = actionTypes; var operatorTypes = System.Enum.GetValues(typeof(ConditionalOperatorTypeEnum)) .Cast <ConditionalOperatorTypeEnum>() .Where(v => !EnumHelper.IsObsolete(v)); this.OperatorTypeComboBox.ItemsSource = operatorTypes; if (this.action != null) { this.CaseSensitiveToggleButton.IsChecked = !this.action.IgnoreCase; this.OperatorTypeComboBox.SelectedItem = this.action.Operator; foreach (ConditionalClauseModel clause in this.action.Clauses) { this.Clauses.Add(new ConditionalClauseViewModel(clause, this)); } if (this.Clauses.Count > 0) { this.Clauses.First().CanBeRemoved = false; } this.Command = this.action.GetCommand(); if (this.action.Action != null) { this.CommandTypeComboBox.SelectedItem = SingleActionCommandType; this.SingleActionNameComboBox.SelectedItem = this.action.Action.Type; this.ActionControlContentControl.Visibility = Visibility.Visible; this.ActionControlContentControl.Content = this.actionContentContainerControl = new ActionContentContainerControl(this.action.Action); } } else { this.OperatorTypeComboBox.SelectedItem = ConditionalOperatorTypeEnum.And; this.Clauses.Add(new ConditionalClauseViewModel(new ConditionalClauseModel(), this) { CanBeRemoved = false }); } this.ClausesItemsControl.ItemsSource = this.Clauses; return(Task.FromResult(0)); }
public override bool HandleEvent(CommandBase command, UserInfo user, List <string> args) => true;
protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { string v1 = await this.ReplaceStringWithSpecialModifiers(this.Value1, user, arguments); string v2 = await this.ReplaceStringWithSpecialModifiers(this.Value2, user, arguments); bool result = false; if (this.ComparisionType == ConditionalComparisionTypeEnum.Contains || this.ComparisionType == ConditionalComparisionTypeEnum.DoesNotContain) { bool contains = v1.IndexOf(v2, this.IgnoreCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture) >= 0; result = ((this.ComparisionType == ConditionalComparisionTypeEnum.Contains && contains) || (this.ComparisionType == ConditionalComparisionTypeEnum.DoesNotContain && !contains)); } else if (this.ComparisionType == ConditionalComparisionTypeEnum.Between) { string v3 = await this.ReplaceStringWithSpecialModifiers(this.Value3, user, arguments); if (double.TryParse(v1, out double v1num) && double.TryParse(v2, out double v2num) && double.TryParse(v3, out double v3num)) { result = (v2num <= v1num && v1num <= v3num); } } else { int compareResult = 0; if (double.TryParse(v1, out double v1num) && double.TryParse(v2, out double v2num)) { if (v1num < v2num) { compareResult = -1; } else if (v1num > v2num) { compareResult = 1; } } else { compareResult = string.Compare(v1, v2, this.IgnoreCase); } if (compareResult == 0 && (this.ComparisionType == ConditionalComparisionTypeEnum.Equals || this.ComparisionType == ConditionalComparisionTypeEnum.GreaterThanOrEqual || this.ComparisionType == ConditionalComparisionTypeEnum.LessThanOrEqual)) { result = true; } else if (compareResult < 0 && (this.ComparisionType == ConditionalComparisionTypeEnum.NotEquals || this.ComparisionType == ConditionalComparisionTypeEnum.LessThan || this.ComparisionType == ConditionalComparisionTypeEnum.LessThanOrEqual)) { result = true; } else if (compareResult > 0 && (this.ComparisionType == ConditionalComparisionTypeEnum.NotEquals || this.ComparisionType == ConditionalComparisionTypeEnum.GreaterThan || this.ComparisionType == ConditionalComparisionTypeEnum.GreaterThanOrEqual)) { result = true; } } if (result) { CommandBase command = this.GetCommand(); if (command != null) { await command.Perform(user, arguments, this.GetExtraSpecialIdentifiers()); } } }
public ConditionalAction(ConditionalComparisionTypeEnum comparisionType, bool ignoreCase, string value1, string value2, string value3, CommandBase command) : this(comparisionType, ignoreCase, value1, value2, command) { this.Value3 = value3; }
public PopinViewModel() { QuitCommand = new CommandBase(onQuit); OpenCommand = new CommandBase(onOpen); }
public void IsUrl_ChecksUrlValidity(string url, bool isUrl) { Assert.AreEqual(isUrl, CommandBase.IsUrl(url)); }
public void ResolveProject_ThrowsIfProjectFileDoesNotExist() { // Act, Assert Assert.Throws <CLIToolException>(() => CommandBase.ResolveProject(new FileInfo("NonExistent"))); }
public static void Main(string[] args) { // get configuration var metadataService = new DotvvmProjectMetadataService(); var metadata = metadataService.FindInDirectory(Directory.GetCurrentDirectory()); if (metadata == null) { Console.WriteLine("No DotVVM project metadata file (.dotvvm.json) was found on current path."); if (ConsoleHelpers.AskForYesNo("Is the current directory the root directory of DotVVM project?")) { Console.WriteLine(); metadata = metadataService.CreateDefaultConfiguration(Directory.GetCurrentDirectory()); metadataService.Save(metadata); } else { Console.WriteLine("There is no DotVVM project metadata file!"); Environment.Exit(1); } } // find applicable command var commands = new CommandBase[] { new AddPageCommand(), new AddMasterPageCommand(), new AddViewModelCommand(), new AddControlCommand(), new AddNswagCommand(), new RegenNswagCommand() //new GenerateUiTestStubCommand() }; var arguments = new Arguments(args); var command = commands.FirstOrDefault(c => c.TryConsumeArgs(arguments, metadata)); // execute the command try { if (command != null) { command.Handle(arguments, metadata); // save project metadata metadataService.Save(metadata); } else { throw new InvalidCommandUsageException("Unknown command!"); } } catch (InvalidCommandUsageException ex) { Console.WriteLine("Invalid Command Usage: " + ex); } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); Console.Error.WriteLine(ex.ToString()); Environment.Exit(1); } }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List <string> args) { // Handling JOIN is done in the ModeInvite class return(true); }
public BookViewModel() { AddBookCommand = new CommandBase(AddBook); EditBookCommand = new CommandBase(EditBook); }
public override void AddCmd(CommandBase cmd) { commands.Add(cmd); }
public override void Do() { base.Do(); Illusion.Game.Utils.Sound.Setting s1 = new Illusion.Game.Utils.Sound.Setting(this.type); int num1 = 0; Illusion.Game.Utils.Sound.Setting setting1 = s1; string[] args1 = this.args; int index1 = num1; int num2 = index1 + 1; string str1 = args1[index1]; setting1.assetBundleName = str1; Illusion.Game.Utils.Sound.Setting setting2 = s1; string[] args2 = this.args; int index2 = num2; int num3 = index2 + 1; string str2 = args2[index2]; setting2.assetName = str2; Illusion.Game.Utils.Sound.Setting setting3 = s1; string[] args3 = this.args; int index3 = num3; int num4 = index3 + 1; double num5; float num6 = (float)(num5 = (double)float.Parse(args3[index3])); setting3.delayTime = (float)num5; this.delayTime = num6; Illusion.Game.Utils.Sound.Setting setting4 = s1; string[] args4 = this.args; int index4 = num4; int num7 = index4 + 1; double num8 = (double)float.Parse(args4[index4]); setting4.fadeTime = (float)num8; Illusion.Game.Utils.Sound.Setting setting5 = s1; string[] args5 = this.args; int index5 = num7; int num9 = index5 + 1; int num10 = bool.Parse(args5[index5]) ? 1 : 0; setting5.isAssetEqualPlay = num10 != 0; Illusion.Game.Utils.Sound.Setting setting6 = s1; string[] args6 = this.args; int index6 = num9; int num11 = index6 + 1; int num12 = bool.Parse(args6[index6]) ? 1 : 0; setting6.isAsync = num12 != 0; Illusion.Game.Utils.Sound.Setting setting7 = s1; string[] args7 = this.args; int index7 = num11; int num13 = index7 + 1; int num14 = int.Parse(args7[index7]); setting7.settingNo = num14; string[] args8 = this.args; int index8 = num13; int num15 = index8 + 1; this.isWait = bool.Parse(args8[index8]); string[] args9 = this.args; int index9 = num15; int num16 = index9 + 1; this.isStop = bool.Parse(args9[index9]); this.transform = Illusion.Game.Utils.Sound.Play(s1); AudioSource audioSource = (AudioSource)((Component)this.transform).GetComponent <AudioSource>(); string[] args10 = this.args; int index10 = num16; int num17 = index10 + 1; Action <string> act1 = (Action <string>)(s => audioSource.set_loop(bool.Parse(s))); args10.SafeProc(index10, act1); string[] args11 = this.args; int index11 = num17; int num18 = index11 + 1; Action <string> act2 = (Action <string>)(s => audioSource.set_pitch(float.Parse(s))); args11.SafeProc(index11, act2); string[] args12 = this.args; int index12 = num18; int num19 = index12 + 1; Action <string> act3 = (Action <string>)(s => audioSource.set_panStereo(float.Parse(s))); args12.SafeProc(index12, act3); string[] args13 = this.args; int index13 = num19; int num20 = index13 + 1; Action <string> act4 = (Action <string>)(s => audioSource.set_spatialBlend(float.Parse(s))); args13.SafeProc(index13, act4); string[] args14 = this.args; int index14 = num20; int num21 = index14 + 1; Action <string> act5 = (Action <string>)(s => audioSource.set_time(float.Parse(s))); args14.SafeProc(index14, act5); string[] args15 = this.args; int index15 = num21; int num22 = index15 + 1; Action <string> act6 = (Action <string>)(s => audioSource.set_volume(float.Parse(s))); args15.SafeProc(index15, act6); string[] args16 = this.args; int index16 = num22; int num23 = index16 + 1; Action <string> act7 = (Action <string>)(s => { Vector3 v; if (!this.scenario.commandController.V3Dic.TryGetValue(s, out v)) { int cnt = 0; CommandBase.CountAddV3(s.Split(','), ref cnt, ref v); } this.transform.set_position(v); }); args16.SafeProc(index16, act7); string[] args17 = this.args; int index17 = num23; int num24 = index17 + 1; Action <string> act8 = (Action <string>)(s => { Vector3 v; if (!this.scenario.commandController.V3Dic.TryGetValue(s, out v)) { int cnt = 0; CommandBase.CountAddV3(s.Split(','), ref cnt, ref v); } this.move = new Vector3?(v); }); args17.SafeProc(index17, act8); string[] args18 = this.args; int index18 = num24; int num25 = index18 + 1; Action <string> act9 = (Action <string>)(s => this.stopTime = new float?(float.Parse(s))); args18.SafeProc(index18, act9); }
public HTTPMemQueuedCommandStorageItem(DateTime dateCreated, RequestStatus requestStatus, CommandBase commandBase) { DateCreated = dateCreated; RequestStatus = requestStatus; CommandBase = commandBase; }
public PetPersister(IList <ColumnInfo <Pet> > columnInfo, IConfiguration config) : base(columnInfo, config) { _connection = new SqlConnection(config.DbConnectionString); _commandBase = new CommandBase <Pet>(columnInfo); }
public void PushMethod(CommandBase command) { this.dispatcher.Push(command); }
public bool HandleEvent(CommandBase command, UserInfo user, List <string> args) { return(Values.All(mode => mode.HandleEvent(command, user, args))); }
public static Command CreateCommandButton(this Commands2 me, AddIn addin, CommandBase command) { object[] contextGUIDS = new object[] { }; Commands2 commands = me; // Try to retrieve the command. If it was created already, just leave since the command exists. Command vsCommand = me.GetCommand(me.GetFullname(addin, command.Name)); if (vsCommand != null) { return(null); // it already exists } try { // Try to create a command with icon. // This usually fails using Visual Studio 2005 if the VsTortoise satellite dll culture does not match the one of Visual Studio. vsCommand = commands.AddNamedCommand2(addin, command.Name, command.Caption, command.Tooltip, false, Type.Missing, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); } catch { } if (vsCommand == null) { // We're here when command creation failed, so create it without icon. vsCommand = commands.AddNamedCommand2(addin, command.Name, command.Caption, command.Tooltip, true, (int)0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); } if (vsCommand != null) { // First check if there is a preferred binding at all, // to skip unnecessary further expensive tests if (!string.IsNullOrEmpty(command.PreferredBinding)) { // The command inside VS has been added. // Now check if any command is using the preferred binding already. // We use it only, when it is not used by another command! // Bindings are "atomic". If we would use a binding that is in use already, // the binding gets removed from the current command. We don't want to steal bindings from other commands! bool bindingUsedAlready = me.GetCommandByBinding(command.PreferredBinding) != null; if (!bindingUsedAlready) { try { // TODO: figure how to assign bindings correctly // Bindings use translated texts, this is so ridiculous. // I don't know how to assign a shortcut in a language independent way, // so we use a try/catch here, otherwise the add-in refuses to start-up. // English: "Text Editor::Ctrl+Shift+Alt+Up Arrow" // German.: "Text-Editor::Strg+Umschalt+Alt+NACH-OBEN-TASTE" vsCommand.Bindings = command.PreferredBinding; } catch { } } } } return(vsCommand); }
public override void AssertPutCommandToLeader(CommandBase cmd) { }
internal abstract CommandRunner GetRunner(CommandBase cb);
public RunAllTestsCommandMenuItem(CommandBase command) : base(command) { }
public FindAllReferencesCommandMenuItem(CommandBase command) : base(command) { }
public RefactorIntroduceParameterCommandMenuItem(CommandBase command) : base(command) { }
public ConditionalAction(ConditionalComparisionTypeEnum comparisionType, bool ignoreCase, string value1, string value2, CommandBase command) : this() { this.ComparisionType = comparisionType; this.IgnoreCase = ignoreCase; this.Value1 = value1; this.Value2 = value2; this.CommandID = command.ID; }
public void ProcessCommand(ClientManager clientManager, object cmd) { Alachisoft.NCache.Common.Protobuf.Command command = cmd as Alachisoft.NCache.Common.Protobuf.Command; if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("CmdMgr.PrsCmd", "enter"); } if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("CmdMgr.PrsCmd", "" + command); } if (SocketServer.Logger.IsDetailedLogsEnabled) { SocketServer.Logger.NCacheLog.Info("ConnectionManager.ReceiveCallback", clientManager.ToString() + " COMMAND to be executed : " + command.type.ToString() + " RequestId :" + command.requestID); } HPTimeStats milliSecWatch = new HPTimeStats(); milliSecWatch.BeginSample(); CommandBase incommingCmd = null; switch (command.type) { case Alachisoft.NCache.Common.Protobuf.Command.Type.INIT: Alachisoft.NCache.Common.Protobuf.InitCommand initCommand = command.initCommand; initCommand.requestId = command.requestID; if (SocketServer.Logger.IsDetailedLogsEnabled) { SocketServer.Logger.NCacheLog.Info("ConnectionManager.ReceiveCallback", clientManager.ToString() + " RequestId :" + command.requestID); } incommingCmd = new InitializeCommand(); break; // added in server to cater getProductVersion request from client case Common.Protobuf.Command.Type.GET_PRODUCT_VERSION: command.getProductVersionCommand.requestId = command.requestID; incommingCmd = new GetProductVersionCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.ADD: command.addCommand.requestId = command.requestID; incommingCmd = new AddCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.ADD_BULK: command.bulkAddCommand.requestId = command.requestID; incommingCmd = new BulkAddCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.CLEAR: command.clearCommand.requestId = command.requestID; incommingCmd = new ClearCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.CONTAINS: command.containsCommand.requestId = command.requestID; incommingCmd = new ContainsCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.COUNT: command.countCommand.requestId = command.requestID; incommingCmd = new CountCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.DISPOSE: command.disposeCommand.requestId = command.requestID; incommingCmd = new DisposeCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET: command.getCommand.requestId = command.requestID; incommingCmd = new GetCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET_BULK: command.bulkGetCommand.requestId = command.requestID; incommingCmd = new BulkGetCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET_CACHE_ITEM: command.getCacheItemCommand.requestId = command.requestID; incommingCmd = new GetCacheItemCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET_ENUMERATOR: command.getEnumeratorCommand.requestId = command.requestID; incommingCmd = new GetEnumeratorCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET_NEXT_CHUNK: command.getNextChunkCommand.requestId = command.requestID; incommingCmd = new GetNextChunkCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET_HASHMAP: command.getHashmapCommand.requestId = command.requestID; incommingCmd = new GetHashmapCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET_OPTIMAL_SERVER: command.getOptimalServerCommand.requestId = command.requestID; incommingCmd = new GetOptimalServerCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET_RUNNING_SERVERS: command.getRunningServersCommand.requestId = command.requestID; incommingCmd = new GetRunningServersCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET_LOGGING_INFO: command.getLoggingInfoCommand.requestId = command.requestID; incommingCmd = new GetLogginInfoCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.GET_TYPEINFO_MAP: command.getTypeInfoMapCommand.requestId = command.requestID; incommingCmd = new GetTypeInfoMap(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.INSERT: command.insertCommand.requestId = command.requestID; incommingCmd = new InsertCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.INSERT_BULK: command.bulkInsertCommand.requestId = command.requestID; incommingCmd = new BulkInsertCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.ISLOCKED: command.isLockedCommand.requestId = command.requestID; incommingCmd = new IsLockedCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.LOCK: command.lockCommand.requestId = command.requestID; incommingCmd = new LockCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.LOCK_VERIFY: command.lockVerifyCommand.requestId = command.requestID; incommingCmd = new VerifyLockCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.REGISTER_KEY_NOTIF: command.registerKeyNotifCommand.requestId = command.requestID; incommingCmd = new RegisterKeyNotifcationCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.REGISTER_NOTIF: command.registerNotifCommand.requestId = command.requestID; incommingCmd = new NotificationRegistered(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.REMOVE: command.removeCommand.requestId = command.requestID; incommingCmd = new RemoveCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.DELETE: command.deleteCommand.requestId = command.requestID; incommingCmd = new DeleteCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.REMOVE_BULK: command.bulkRemoveCommand.requestId = command.requestID; incommingCmd = new BulkRemoveCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.DELETE_BULK: command.bulkDeleteCommand.requestId = command.requestID; incommingCmd = new BulkDeleteCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.SEARCH: Alachisoft.NCache.Common.Protobuf.SearchCommand searchCommand = command.searchCommand; searchCommand.requestId = command.requestID; if (searchCommand.searchEntries) { incommingCmd = new SearchEnteriesCommand(); } else { incommingCmd = new SearchCommand(); } break; case Alachisoft.NCache.Common.Protobuf.Command.Type.UNLOCK: command.unlockCommand.requestId = command.requestID; incommingCmd = new UnlockCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.UNREGISTER_KEY_NOTIF: command.unRegisterKeyNotifCommand.requestId = command.requestID; incommingCmd = new UnRegisterKeyNoticationCommand(); break; case Alachisoft.NCache.Common.Protobuf.Command.Type.ADD_ATTRIBUTE: command.addAttributeCommand.requestId = command.requestID; incommingCmd = new AddAttributeCommand(); break; } if (SocketServer.IsServerCounterEnabled) { _perfStatsCollector.MsecPerCacheOperationBeginSample(); } ///*****************************************************************/ ///**/incommingCmd.ExecuteCommand(clientManager, command, value);/**/ ///*****************************************************************/ //PROTOBUF /*****************************************************************/ /**/ incommingCmd.ExecuteCommand(clientManager, command);/**/ /*****************************************************************/ if (SocketServer.Logger.IsDetailedLogsEnabled) { SocketServer.Logger.NCacheLog.Info("ConnectionManager.ReceiveCallback", clientManager.ToString() + " after executing COMMAND : " + command.type.ToString() + " RequestId :" + command.requestID); } if (SocketServer.IsServerCounterEnabled) { _perfStatsCollector.MsecPerCacheOperationEndSample(); } if (clientManager != null && incommingCmd.SerializedResponsePackets != null && !clientManager.IsCacheStopped) { if (SocketServer.IsServerCounterEnabled) { _perfStatsCollector.IncrementResponsesPerSecStats(1); } foreach (byte[] reponse in incommingCmd.SerializedResponsePackets) { ConnectionManager.AssureSend(clientManager, reponse, Alachisoft.NCache.Common.Enum.Priority.Normal); } } if (ServerMonitor.MonitorActivity) { ServerMonitor.LogClientActivity("CmdMgr.PrsCmd", "exit"); } }