Ejemplo n.º 1
0
 public override int ExecuteNonQuery()
 {
     ExecutedParameterCollections.Add(new FakeParameterCollection(_parameters));
     CommandStrings.Add(CommandText);
     ExecuteNonQueryInvoked = true;
     return(ExecuteNonQueryResult);
 }
Ejemplo n.º 2
0
 public override object ExecuteScalar()
 {
     CommandStrings.Add(CommandText);
     ExecutedParameterCollections.Add(new FakeParameterCollection(_parameters));
     ExecuteScalarInvoked = true;
     return(ExecuteScalarResult);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a ShellCommandEntry for each command in a given command library, and inserts the command's
        /// name into CommandStrings to make it a valid command according to the parser.
        /// </summary>
        /// <param name="commands"> An enumerable object containing a set of command descriptors. </param>
        /// <param name="handler"> A handler to be associated with the set of command descriptors. </param>
        /// <returns> Returns true on success and false if a command is rejected. </returns>
        public bool registerCommands(IEnumerable <CommandDescriptor> commands, ICommandHandler handler)
        {
            try
            {
                foreach (var command in commands)
                {
                    _commands.Add(
                        command.Name.ToLower(),
                        new ShellCommandEntry
                    {
                        Descriptor = command,
                        Handler    = handler
                    }
                        );
                    CommandStrings.Add(command.Name);
                }

                return(true);
            }
            catch (Exception e)
            {
                Processor.Executor.WriteInfoText(e.Message);
                return(false);
            }
        }
Ejemplo n.º 4
0
        public Task GenerateCommandsList()
        {
            var cmds = _cmds.Commands.Select(c => (model: CommandStrings.GetCommandStringModel(c.Name), cmd: c)).GroupBy(m => m.cmd.Module.IsSubmodule ? m.cmd.Module.Parent : m.cmd.Module).OrderBy(g => g.Key.Name).ToDictionary(k => k.Key.Name.ToLower(), k => k.Select(c => c.model).Distinct().OrderBy(c => c.Name).ToArray());

            Directory.CreateDirectory("./docs/");
            var serializer = new SerializerBuilder().DisableAliases().Build();

            File.WriteAllText("./docs/commandstrings.yaml", serializer.Serialize(cmds));
            return(Task.CompletedTask);
        }
Ejemplo n.º 5
0
        public void AddCommand(string commandstring)
        {
            CommandStrings.Add(commandstring);
            ArgumentNode an = new ArgumentNode(commandstring);

            if (an.Key != null)
            {
                Commands.Add(an.Key, an);
            }
            else
            {
                throw new ArgumentException("Outermost command must have a name");
            }
        }
Ejemplo n.º 6
0
 public Description([CallerMemberName] string memberName = "") : base(CommandStrings.GetCommandStringModel(memberName.ToLowerInvariant()).Description)
 {
 }
Ejemplo n.º 7
0
 public NadekoCommand([CallerMemberName] string memberName = "")
     : base(CommandStrings.GetCommandStringModel(memberName.ToLowerInvariant()).Command)
 {
 }
Ejemplo n.º 8
0
 private void InitCommandSet(ref CommandStrings CommandSet)
 {
   CommandSet.BaudRate = string.Empty;
   CommandSet.Parity = "None";
   CommandSet.DataBits = "8";
   CommandSet.StopBits = "1";
   CommandSet.CommDelay = Settings.Instance.TextComDelay;
   CommandSet.CMD_DisplayInit = string.Empty;
   CommandSet.CMD_ClearDisplay = string.Empty;
   CommandSet.CMD_CursorLeft = string.Empty;
   CommandSet.CMD_CursorRight = string.Empty;
   CommandSet.CMD_CursorUp = string.Empty;
   CommandSet.CMD_CursorDown = string.Empty;
   CommandSet.CMD_CursorHome = string.Empty;
   CommandSet.CMD_ToggleRTS = false;
   CommandSet.CMD_ToggleDTR = false;
 }
Ejemplo n.º 9
0
 public Description([CallerMemberName] string memberName = "") : base(CommandStrings.GetCommandStringModel(memberName).Description)
 {
 }
Ejemplo n.º 10
0
 public Aliases([CallerMemberName] string memberName = "") : base(CommandStrings.GetCommandStringModel(memberName.ToLowerInvariant()).Aliases)
 {
 }
Ejemplo n.º 11
0
 internal static string JoinRun_OptionUnknown(string optionName, string groupName) =>
 $"Failed to join round. Unknown option *{optionName}*. " + CommandStrings.AddOption(groupName, optionName);
Ejemplo n.º 12
0
 internal static string AddOption_BadArguments() =>
 "Failed to add option. Invalid command. " + CommandStrings.AddOption();
Ejemplo n.º 13
0
 internal static string StartRun_GroupNoOptions(string groupName) =>
 $"Cannot start round. *{groupName}* has no options. " + CommandStrings.AddOption(groupName);
Ejemplo n.º 14
0
 protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
 {
     CommandStrings.Add(CommandText);
     ExecutedParameterCollections.Add(new FakeParameterCollection(_parameters));
     return(new FakeDataReader(NextResult.Clone()));
 }
Ejemplo n.º 15
0
 public Usage([CallerMemberName] string memberName = "") : base(CommandStrings.GetCommandStringModel(memberName.ToLowerInvariant()).Usage)
 {
 }
Ejemplo n.º 16
0
 public Usage([CallerMemberName] string memberName = "") : base(CommandStrings.GetCommandStringModel(memberName).Usage)
 {
 }
Ejemplo n.º 17
0
 public Aliases([CallerMemberName] string memberName = "") : base(CommandStrings.GetCommandStringModel(memberName).Aliases)
 {
 }
Ejemplo n.º 18
0
 //Add option
 internal static string AddOption_GroupInvalidName(string groupName) =>
 $"Failed to add option. *{groupName}* is not a valid group. " + CommandStrings.AddGroup(groupName);
Ejemplo n.º 19
0
 public new IDataReader ExecuteReader(CommandBehavior behavior)
 {
     CommandStrings.Add(CommandText);
     ExecutedParameterCollections.Add(new FakeParameterCollection(_parameters));
     return(ExecuteReaderResult);
 }
Ejemplo n.º 20
0
 internal static string RemoveGroup_BadArguments() =>
 "Failed to remove group. Invalid command. " + CommandStrings.AddOption();
Ejemplo n.º 21
0
 private bool InitCommandSet(CommandStrings CommandStrings)
 {
   this.Commands.CMD_DisplayInit = null;
   this.Commands.CMD_ClearDisplay = null;
   this.Commands.CMD_CursorLeft = null;
   this.Commands.CMD_CursorRight = null;
   this.Commands.CMD_CursorUp = null;
   this.Commands.CMD_CursorDown = null;
   this.Commands.CMD_CursorHome = null;
   this.Commands.CMD_CursorSet = null;
   this.Commands.CMD_DisplayClose = null;
   this.Commands.PositionBase = CommandStrings.PositionBase;
   this.Commands.CMD_ToggleRTS = CommandStrings.CMD_ToggleRTS;
   this.Commands.CMD_ToggleDTR = CommandStrings.CMD_ToggleDTR;
   this.Commands.AssertRTS = CommandStrings.AssertRTS;
   this.Commands.AssertDTR = CommandStrings.AssertDTR;
   this.Commands.CMD_DisplayInit = this.CommandStringToBytes(CommandStrings.CMD_DisplayInit);
   this.DebugShowCommand("Commands.CMD_DisplayInit", this.Commands.CMD_DisplayInit);
   this.Commands.CMD_ClearDisplay = this.CommandStringToBytes(CommandStrings.CMD_ClearDisplay);
   this.DebugShowCommand("Commands.CMD_ClearDisplay", this.Commands.CMD_ClearDisplay);
   this.Commands.CMD_CursorLeft = this.CommandStringToBytes(CommandStrings.CMD_CursorLeft);
   this.DebugShowCommand("Commands.CMD_CursorLeft", this.Commands.CMD_CursorLeft);
   this.Commands.CMD_CursorRight = this.CommandStringToBytes(CommandStrings.CMD_CursorRight);
   this.DebugShowCommand("Commands.CMD_CursorRight", this.Commands.CMD_CursorRight);
   this.Commands.CMD_CursorUp = this.CommandStringToBytes(CommandStrings.CMD_CursorUp);
   this.DebugShowCommand("Commands.CMD_CursorUp", this.Commands.CMD_CursorUp);
   this.Commands.CMD_CursorDown = this.CommandStringToBytes(CommandStrings.CMD_CursorDown);
   this.DebugShowCommand("Commands.CMD_CursorDown", this.Commands.CMD_CursorDown);
   this.Commands.CMD_CursorHome = this.CommandStringToBytes(CommandStrings.CMD_CursorHome);
   this.DebugShowCommand("Commands.CMD_CursorHome", this.Commands.CMD_CursorHome);
   this.Commands.CMD_CursorHome = this.CommandStringToBytes(CommandStrings.CMD_CursorSet);
   this.DebugShowCommand("Commands.CMD_CursorSet", this.Commands.CMD_CursorSet);
   this.Commands.CMD_DisplayClose = this.CommandStringToBytes(CommandStrings.CMD_DisplayClose);
   this.DebugShowCommand("Commands.CMD_DisplayClose", this.Commands.CMD_DisplayClose);
   return (this.Commands.CMD_DisplayInit != null);
 }
Ejemplo n.º 22
0
 //Start
 internal static string StartRun_GroupInvalidName(string groupName) =>
 $"Failed to start round. *{groupName}* is not a valid group. " + CommandStrings.AddGroup(groupName);
Ejemplo n.º 23
0
 public bool OpenDisplay(string _port, int dRows, int dCols, CommandStrings DefinedCommandStrings)
 {
   this.DoDebug = Settings.Instance.ExtensiveLogging;
   Log.Info("GenericSerial.GSDisplay.OpenDisplay(): Called");
   if (!this.InitCommandSet(DefinedCommandStrings))
   {
     Log.Info("GenericSerial.GSDisplay.OpenDisplay(): Command Set not properly defined!!");
     this._isOpen = false;
     return false;
   }
   Log.Info("GenericSerial.GSDisplay.OpenDisplay(): Command Set loaded");
   try
   {
     int num;
     int num2;
     string str2;
     this._DisplayLines = dRows;
     this._DisplayColumns = dCols;
     this._CurrentLine = 0;
     this._CurrentColumn = 0;
     this.CommDelay = DefinedCommandStrings.CommDelay;
     if (DefinedCommandStrings.BaudRate == string.Empty)
     {
       num = 0x2580;
     }
     else
     {
       num = int.Parse(DefinedCommandStrings.BaudRate);
     }
     if (DefinedCommandStrings.DataBits == string.Empty)
     {
       num2 = 8;
     }
     else
     {
       num2 = int.Parse(DefinedCommandStrings.DataBits);
     }
     string str = DefinedCommandStrings.Parity;
     if (str == null)
     {
       goto Label_0130;
     }
     if (!(str == "Even"))
     {
       if (str == "Mark")
       {
         goto Label_0120;
       }
       if (str == "None")
       {
         goto Label_0124;
       }
       if (str == "Odd")
       {
         goto Label_0128;
       }
       if (str == "Space")
       {
         goto Label_012C;
       }
       goto Label_0130;
     }
     Parity even = Parity.Even;
     goto Label_0132;
     Label_0120:
     even = Parity.Mark;
     goto Label_0132;
     Label_0124:
     even = Parity.None;
     goto Label_0132;
     Label_0128:
     even = Parity.Odd;
     goto Label_0132;
     Label_012C:
     even = Parity.Space;
     goto Label_0132;
     Label_0130:
     even = Parity.None;
     Label_0132:
     if ((str2 = DefinedCommandStrings.StopBits) == null)
     {
       goto Label_0188;
     }
     if (!(str2 == "None"))
     {
       if (str2 == "One")
       {
         goto Label_017C;
       }
       if (str2 == "OnePointFive")
       {
         goto Label_0180;
       }
       if (str2 == "Two")
       {
         goto Label_0184;
       }
       goto Label_0188;
     }
     StopBits none = StopBits.None;
     goto Label_018A;
     Label_017C:
     none = StopBits.One;
     goto Label_018A;
     Label_0180:
     none = StopBits.OnePointFive;
     goto Label_018A;
     Label_0184:
     none = StopBits.Two;
     goto Label_018A;
     Label_0188:
     none = StopBits.None;
     Label_018A:
     ;
     Log.Info(
       "GenericSerial.GSDisplay.OpenDisplay(): Opening display - Port = {0}, Baud = {1}, DataBits = {2}, Parity = {3}, StopBits = {4}, CommDelay = {5}",
       new object[]
         {_port, num.ToString(), num2.ToString(), even.ToString(), none.ToString(), this.CommDelay.ToString()});
     this.commPort = new SerialPort(_port, num, even, num2, none);
     this.commPort.Open();
     Log.Info("GenericSerial.GSDisplay.OpenDisplay(): Comm Port {0} opened", new object[] {_port});
     if (this.Commands.AssertRTS)
     {
       this.commPort.RtsEnable = true;
     }
     if (this.Commands.AssertDTR)
     {
       this.commPort.DtrEnable = true;
     }
     this.InitDisplay();
     this.ClearDisplay();
     this._IsDisplayOff = false;
     this._isOpen = true;
   }
   catch (Exception exception)
   {
     Log.Info("GenericSerial.GSDisplay.OpenDisplay(): CAUGHT EXCEPTION while opening display! \n{0}",
              new object[] {exception});
     if (this.commPort.IsOpen)
     {
       this.commPort.Close();
     }
     this._isOpen = false;
   }
   Log.Info("GenericSerial.GSDisplay.OpenDisplay(): Completed - Returning {0}",
            new object[] {this._isOpen.ToString()});
   return this._isOpen;
 }
Ejemplo n.º 24
0
 public bool IsSendable()
 {
     if (Header == null)
     {
         return(false);
     }
     if (Header.PayloadType == MessagePayloadType.Object && PayloadObject == null)
     {
         return(false);
     }
     if (Header.PayloadType == MessagePayloadType.CommandString && (CommandStrings == null || !CommandStrings.Any() || CommandStrings.All(string.IsNullOrWhiteSpace)))
     {
         return(false);
     }
     if (Header.PayloadType == MessagePayloadType.Raw && (RawFrames == null || !RawFrames.Any() || RawFrames.All(rf => rf.Length == 0)))
     {
         return(false);
     }
     return(Header.IsSendable());
 }
Ejemplo n.º 25
0
 public MitternachtCommand([CallerMemberName] string memberName = "") : base(CommandStrings.GetCommandStringModel(memberName).Command)
 {
 }