private static string[] ConstructCommand(SupportedCommands command, string[] commandParameters) { string[] result = new string[commandParameters.Length + 1]; switch (command) { //{ Enum.GetName(typeof(SupportedCommands), SupportedCommands.find), command[1]} case SupportedCommands.Add: result[0] = Enum.GetName(typeof(SupportedCommands), SupportedCommands.find); break; case SupportedCommands.find: result[0] = Enum.GetName(typeof(SupportedCommands), SupportedCommands.find); break; case SupportedCommands.serialize: result[0] = Enum.GetName(typeof(SupportedCommands), SupportedCommands.find); break; default: throw new ArgumentOutOfRangeException($"Unrecognized command {command}"); } int index = 1; foreach (string param in commandParameters) { result[index++] = param; } return(result); }
public void Dispose() { if (IsDisposed) { return; } IsDisposed = true; if (CommandViewFactory != null) { CommandViewFactory.Dispose(); } _config = null; _parser = null; _gestureView = null; _intentStore = null; _pathTracker = null; SupportedCommands.Clear(); SupportedCommands = null; CommandViewFactory = null; _form.Dispose(); _form = null; //GC.Collect(); }
public static string[] ParseCommand(string command) { string[] extractedCommand = extractCommand(command); SupportedCommands commandFound = (SupportedCommands)Enum.Parse(typeof(SupportedCommands), extractedCommand[0]); switch (commandFound) { case SupportedCommands.Add: if (!isAddCommandCorrect(extractedCommand)) { throw new FormatException($"Invalid {commandFound} passed - check syntax!"); } break; case SupportedCommands.find: if (!isFindCommandCorrect(extractedCommand)) { throw new FormatException($"Invalid {commandFound} passed - check syntax!"); } break; case SupportedCommands.serialize: if (!isSerializeCommandCorrect(extractedCommand)) { throw new FormatException($"Invalid {commandFound} passed - check syntax!"); } break; default: throw new ArgumentException($"Unrecognized command passed: {command} "); } return(extractedCommand); }
public IEnumerable <string> SuggestCandidates(string text) { if (string.IsNullOrWhiteSpace(text)) { return(SupportedCommands.Select(c => c.Key)); } var segments = text .Split(' ') .Select(s => s.Trim()) .ToList(); var command = segments.FirstOrDefault(); if (command == null || segments.Count < 1) { return(Enumerable.Empty <string>()); } if (!command.EndsWith(" ") && segments.Count == 1) { return(SupportedCommands.Where(c => c.Key.StartsWith(command)).Select(c => c.Key)); } var arguments = string.Join(" ", segments.Skip(1)); return(SupportedCommands .Where(c => c.Key == command) .OfType <IAutoCompletionSupport>() .SelectMany(c => c.SuggestCandidates(arguments)) .Select(s => string.Join(" ", command, s))); }
public override void Initialize() { if (SupportedCommands.Contains(DeviceCommands.GetStatus)) { GetStatus(); } }
protected VSCommandTarget(IVsTextView vsTextView, IWpfTextView textView) { TextView = textView; CommandGroupId = typeof(T).GUID; CommandIdSet = new HashSet <uint>(SupportedCommands.Select(x => ConvertFromCommand(x))); _NextCommandTarget = AttachTo(vsTextView, this); }
protected AI_HS2_TextResourceHelper() { FormatKeys = new HashSet <string>(new[] { "パターン", "セリフ" }); SupportedCommands.Add(Command.Calc); SupportedCommands.Add(Command.Format); SupportedCommands.Add(Command.Choice); SupportedCommands.Add((Command)242); }
public virtual void PaperCut() { if (SupportedCommands.Contains(DeviceCommands.GetStatus)) { GetStatus(); } SendMessage(defaultEnc.GetBytes("\n \n \n \n\x1B\x69")); }
protected Command(char identifier) { if (!SupportedCommands.Contains(identifier)) { throw new UnsupportedCommandIdentiferException(identifier); } Identifier = identifier; }
protected AI_HS2_TextResourceHelper() { SupportedCommands.Add(Command.Calc); SupportedCommands.Add(Command.Choice); SupportedCommands.Add((Command)242); // TextDump sometimes picks up this column header, so workaround here. TextKeysBlacklist.Add("表示名"); }
private void SetCommand(string commandName) { if (!SupportedCommands.Contains(commandName, StringComparer.CurrentCultureIgnoreCase)) { BadOption("command"); } ; CommandName = commandName; }
public SettingsFormController(IConfig config, GestureParser parser, Win32MousePathTracker2 pathTracker, JsonGestureIntentStore intentStore, CanvasWindowGestureView gestureView, GlobalHotKeyManager hotkeyMgr) { _config = config; _parser = parser; _pathTracker = pathTracker; _intentStore = intentStore; _gestureView = gestureView; _hotkeyMgr = hotkeyMgr; #region 初始化支持的命令和命令视图 //Add Command Types SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(DoNothingCommand)), typeof(DoNothingCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(HotKeyCommand)), typeof(HotKeyCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(WebSearchCommand)), typeof(WebSearchCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(WindowControlCommand)), typeof(WindowControlCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(TaskSwitcherCommand)), typeof(TaskSwitcherCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(OpenFileCommand)), typeof(OpenFileCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(SendTextCommand)), typeof(SendTextCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(GotoUrlCommand)), typeof(GotoUrlCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(CmdCommand)), typeof(CmdCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(ScriptCommand)), typeof(ScriptCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(PauseWGesturesCommand)), typeof(PauseWGesturesCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(ChangeAudioVolumeCommand)), typeof(ChangeAudioVolumeCommand)); SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(AddToBacklistCommand)), typeof(AddToBacklistCommand)); CommandViewFactory.Register <AddToBacklistCommand, GeneralNoParameterCommandView>(); CommandViewFactory.Register <OpenFileCommand, OpenFileCommandView>(); CommandViewFactory.Register <DoNothingCommand, GeneralNoParameterCommandView>(); CommandViewFactory.Register <HotKeyCommand, HotKeyCommandView>(); CommandViewFactory.Register <GotoUrlCommand, GotoUrlCommandView>(); CommandViewFactory.Register <PauseWGesturesCommand, GeneralNoParameterCommandView>(); CommandViewFactory.Register <WebSearchCommand, WebSearchCommandView>(); CommandViewFactory.Register <WindowControlCommand, WindowControlCommandView>(); CommandViewFactory.Register <CmdCommand, CmdCommandView>(); CommandViewFactory.Register <SendTextCommand, SendTextCommandView>(); CommandViewFactory.Register <TaskSwitcherCommand, TaskSwitcherCommandView>(); CommandViewFactory.Register <ScriptCommand, ScriptCommandView>(); CommandViewFactory.Register <ChangeAudioVolumeCommand, GeneralNoParameterCommandView>(); #endregion #region Hotcorner SupportedHotCornerCommands.Add(NamedAttribute.GetNameOf(typeof(DoNothingCommand)), typeof(DoNothingCommand)); SupportedHotCornerCommands.Add(NamedAttribute.GetNameOf(typeof(HotKeyCommand)), typeof(HotKeyCommand)); SupportedHotCornerCommands.Add(NamedAttribute.GetNameOf(typeof(CmdCommand)), typeof(CmdCommand)); HotCornerCommandViewFactory.Register <DoNothingCommand, GeneralNoParameterCommandView>(); HotCornerCommandViewFactory.Register <HotKeyCommand, HotKeyCommandView>(); HotCornerCommandViewFactory.Register <CmdCommand, CmdCommandView>(); #endregion _form = new SettingsForm(this); }
public override async Task <ReadResult> ReadAsync(Command request, DeviceOperationScope scope, AsyncOperationInfo cancellation) { if (SupportedCommands.Contains(request)) { return(await _base.ReadAsync(request, scope, cancellation)); } else { return(new ReadResult(ReadStatus.NOT_SUPPORTED_BY_INTERFACE, Enumerable.Empty <IDataEntity>(), ResponseData.NONE)); } }
public override async Task <BurnResult> BurnAsync(Command request, IEnumerable <IDataEntity> entities, DeviceOperationScope scope, AsyncOperationInfo cancellation) { if (SupportedCommands.Contains(request)) { return(await _base.BurnAsync(request, entities, scope, cancellation)); } else { return(new BurnResult(BurnStatus.NOT_SUPPORTED_BY_INTERFACE, ResponseData.NONE)); } }
protected Command(byte commandNumber, IEnumerable <byte> data) { if (!SupportedCommands.Contains(commandNumber)) { throw new InvalidOperationException("Unsupported command: " + commandNumber); } ValidateCommand(commandNumber, data); CommandNumber = commandNumber; Data = data; }
protected AI_TextResourceHelper() { // Format commands with a key of `セリフ` can be handled by TextDump/TextResourceRedirector // others are used to make programmatic labels and should be untouched SupportedCommands.Add(Command.Format); FormatKeys.Add("セリフ"); CalcKeys.Add("want"); // adding known format key that we don't handle to ensure we don't try and translated it TextKeysBlacklist.Add("パターン"); }
public bool UseUTF8() { if (SupportedCommands.Contains("UTF8")) { SendCommandReadAnswer("OPTS UTF8 ON"); if (ConnectionType == 200) { return(true); } } return(false); }
internal virtual Dictionary <string, IEnumerable <string> > GetSettingsStrings() { return(new Dictionary <string, IEnumerable <string> > { { nameof(TextKeysBlacklist), TextKeysBlacklist }, { nameof(CalcKeys), CalcKeys }, { nameof(FormatKeys), FormatKeys }, { nameof(SupportedCommands), SupportedCommands.Select(c => c.ToString()) }, { nameof(SpecializedKeyCommands), SpecializedKeyCommands.Select(c => c.ToString()) }, { nameof(GetRandomNameDirs), GetRandomNameDirs().ToList() }, { nameof(GetScenarioDirs), GetScenarioDirs().ToList() } }); }
public virtual void PrintFreeText(string text) { if (SupportedCommands.Contains(DeviceCommands.GetStatus)) { GetStatus(); } text = text.Replace("\r\n", "\n"); text = text.Replace("\r", "\n"); text = string.Join("\n", text.Wrap(textCharsPerLine, 20)); text += "\n"; SendMessage(GetTextBytes(text)); }
public void GetSupportedCommands() { _checkConnected(); string answer = SendCommandReadAnswer("FEAT", null, "211"); foreach (string item in answer.Split('\n')) { if (item.Trim().Length > 0 && !item.Trim().StartsWith("211")) { SupportedCommands.Add(item.Trim()); } } }
protected KKS_TextResourceHelper() { SupportedCommands.Add(Command.Choice); foreach (var selectionCommand in SelectionCommands) { SupportedCommands.Add(selectionCommand); SpecializedKeyCommands.Add(selectionCommand); } // TextDump sometimes picks up this column header, so workaround here. TextKeysBlacklist.Add("表示名"); TextKeysBlacklist.Add("名称"); TextKeysBlacklist.Add("タイトル"); TextKeysBlacklist.Add("Name"); }
private bool ComMan_OnReceivedPack(object sender, Packet p) { //! Check if it's supported Command for this interface if (SupportedCommands.Any(i => i == p.Command) == false) { return(false); } //! Check if it's interface port if (p.CommandParam != Port) { return(false); } OnReceiceNewPacket?.Invoke(this, p); return(true); }
internal void ResetSupportedCommandList() { SupportedCommands.Clear(); SupportedCommands.Add(NNTPMessages.Article, false); SupportedCommands.Add(NNTPMessages.Group, false); SupportedCommands.Add(NNTPMessages.Help, true); SupportedCommands.Add(NNTPMessages.NewNews, false); SupportedCommands.Add(NNTPMessages.ListGroup, false); SupportedCommands.Add(NNTPMessages.ListNewsGroups, false); SupportedCommands.Add(NNTPMessages.NewsGroups, false); SupportedCommands.Add(NNTPMessages.Next, false); SupportedCommands.Add(NNTPMessages.Post, false); SupportedCommands.Add(NNTPMessages.Quit, false); SupportedCommands.Add(NNTPMessages.Slave, false); SupportedCommands.Add(NNTPMessages.AuthInfoUser, false); SupportedCommands.Add(NNTPMessages.AuthInfoPass, false); SupportedCommands.Add(NNTPMessages.AuthInfoGeneric, false); SupportedCommands.Add(NNTPMessages.Head, false); SupportedCommands.Add(NNTPMessages.Body, false); SupportedCommands.Add(NNTPMessages.Ihave, false); }
private void _useExplicitSSL() { if (!SupportedCommands.Contains("AUTH TLS")) { return; } if (ActiveClient != null) { string answer = SendCommandReadAnswer("AUTH TLS"); if (ConnectionType == 234) { SslStream sslStream = new SslStream(ActiveClient.GetStream(), false, _validateServerCertificate); sslStream.AuthenticateAsClient(realServer); _activeClientStream = sslStream; ActiveClientReader = new BinaryReader(_activeClientStream); ActiveClientWriter = new StreamWriter(_activeClientStream); } } }
protected AI_TextResourceHelper() { SupportedCommands.Add(Command.Switch); // Definately don't want this in HS2 CalcKeys = new HashSet <string>(new[] { "want" }); }
public virtual bool MayHandle(string initiator, string command) { return(SupportedInitiators.Any(i => i.Equals(initiator, StringComparison.OrdinalIgnoreCase)) && SupportedCommands.Any(c => c.Equals(command, StringComparison.OrdinalIgnoreCase))); }
public Command(SupportedCommands cmd, IList<string> args = null) { Cmd = cmd; Args = args ?? new string[0]; }
public override void Awake() { SupportedCommands.Add(CommandType.AUTO_ATTACK); }
public bool IsSupportedCommand(Command command) { return(SupportedCommands.Contains(command)); }
protected KK_TextResourceHelper() { SupportedCommands.Add(Command.Choice); SupportedCommands.Add((Command)242); }
/// <summary> /// Executes a command and returns a corresponding response. /// </summary> /// <param name="command">The command.</param> protected virtual Response ExecuteCommand(Command command) { switch (command.Name) { case "protocol_version": return(new Response(command, "2")); case "name": return(new Response(command, this.Name.Replace('\n', ' '))); case "version": return(new Response(command, this.Version.Replace('\n', ' '))); case "list_commands": return(new Response(command, string.Join("\n", this.SupportedCommands))); case "known_command": return(new Response( command, command.Arguments.Count > 0 && SupportedCommands.Contains(command.Arguments[0]) ? "true" : "false" )); case "quit": return(new Response(command)); case "boardsize": try { int size = int.Parse(command.Arguments[0]); if (size > 25) { throw new Exception(); } this.Board = new Board(size); return(new Response(command)); } catch {} return(new Response(command, "unacceptable size", true)); case "clear_board": this.MoveHistory.Clear(); this.Board.Clear(); return(new Response(command)); case "komi": try { this.Komi = float.Parse(command.Arguments[0]); return(new Response(command)); } catch {} return(new Response(command, "syntax error", true)); case "fixed_handicap": if (!this.Board.IsEmpty()) { return(new Response(command, "board not empty", true)); } try { int count = int.Parse(command.Arguments[0]); if (count < 2 || count > 9 || this.Board.Size < 7) { return(new Response(command, "invalid number of stones", true)); } foreach (Vertex v in Board.GetHandicapPlacement(count)) { Board[v] = 1; } return(new Response(command)); } catch {} return(new Response(command, "syntax error", true)); case "set_free_handicap": if (!this.Board.IsEmpty()) { return(new Response(command, "board not empty", true)); } try { List <Vertex> vs = new List <Vertex>(); foreach (string input in command.Arguments) { Vertex v = new Vertex(input); if (v == Vertex.Pass || vs.Contains(v)) { return(new Response(command, "bad vertex list", true)); } vs.Add(v); } foreach (Vertex v in vs) { this.Board[v] = 1; } return(new Response(command)); } catch {} return(new Response(command, "syntax error", true)); case "play": try { Move move = Move.Parse(string.Join(" ", command.Arguments)); this.Play(move); return(new Response(command)); } catch (FormatException) { return(new Response(command, "syntax error", true)); } catch (InvalidOperationException) { return(new Response(command, "illegal move", true)); } case "genmove": try { Color color = (Color)Enum.Parse(typeof(Color), command.Arguments[0], true); Vertex?vertex = GenerateMove(color); if (vertex.HasValue) { // Make move and add to move history Move move = new Move(color, vertex.Value); this.Play(move); } return(new Response(command, vertex.HasValue ? vertex.ToString() : "resign")); } catch {} return(new Response(command, "syntax error", true)); case "undo": if (MoveHistory.Count == 0) { return(new Response(command, "cannot undo", true)); } Tuple <Move, Board> tuple = MoveHistory.Pop(); this.Board = tuple.Item2; return(new Response(command)); case "showboard": string result = this.Board.ToString() + "\n-\n"; result += "(X) captured " + this.Board.Captures[Color.Black] + "\n"; result += "(O) captured " + this.Board.Captures[Color.White]; return(new Response(command, result)); } return(new Response(command, "unknown command", true)); }