コード例 #1
0
        public List <ArduinoCommand> GetCommands(FilterCommandsOptions options = FilterCommandsOptions.ALL)
        {
            List <ArduinoCommand> commands = new List <ArduinoCommand>();

            if (_commands == null || _commands.Count == 0)
            {
                return(commands);
            }

            commands = _commands.Values.ToList();
            switch (options)
            {
            case FilterCommandsOptions.BASE_ONLY:
                commands = commands.Where <ArduinoCommand>(x => !x.IsCompound).ToList();
                break;

            case FilterCommandsOptions.COMPOUND_ONLY:
                commands = commands.Where <ArduinoCommand>(x => x.IsCompound).ToList();
                break;

            case FilterCommandsOptions.BY_TYPE:
                throw new NotImplementedException("Not yet implemented");
            }
            return(commands);
        }
コード例 #2
0
 virtual public void ClearCommands(FilterCommandsOptions options = FilterCommandsOptions.ALL)
 {
     if (options == FilterCommandsOptions.ALL)
     {
         _commands.Clear();
     }
     else
     {
         List <ArduinoCommand> commands2remove = GetCommands(options);
         foreach (var cmd in commands2remove)
         {
             _commands.Remove(cmd.CommandAlias);
         }
     }
 }