public static void AddInterpreter(CommandParameterInterpreter interpreter)
 {
     if (!InterpretersByType.ContainsKey(interpreter.Type))
     {
         InterpretersByType.Add(interpreter.Type, interpreter);
     }
 }
示例#2
0
        private void PrepareParameterEdition()
        {
            CommandParameterInfo paramInfo = Info.CommandParameterInfo[CurrentParameterID];

            currentInterpreter = CommandParameterInterpreter.
                                 GetInterpreter(paramInfo.ParameterType);
            CurrentTextEntered = TextEntered[CurrentParameterID];

            CurrentAutoComplete = paramInfo.HasAutoComplete
                ? paramInfo.AutoComplete
                : AutoCompleteManager.GetDefaultAutoComplete(IsArray ?
                                                             paramInfo.ParameterType.GetElementType() :
                                                             paramInfo.ParameterType);

            CurrentAutoComplete?.InitializeAutoComplete();

            CurrentAutoCompleteID = -1;

            if (!CurrentParameterInfo.PreventDefaultValueUsage && CurrentParameterInfo.HadDefaultValue && CurrentAutoComplete != null)
            {
                if (CurrentAutoComplete.Count == 0)
                {
                    CurrentAutoComplete.GenerateAndSortAutoComplete("");
                }

                for (int i = 0; i < CurrentAutoComplete.Count; i++)
                {
                    if (CurrentAutoComplete.GetValue(i).Equals(CurrentParameterInfo.DefaultValue))
                    //   if (CurrentAutoComplete.GetValue(i).ToString() == CurrentParameterInfo.DefaultValue.ToString())
                    {
                        CurrentAutoCompleteID = i;
                        break;
                    }
                }
            }

            if (IsArray)
            {
                CurrentArrayTextEntered  = arrayTextEntered[CurrentParameterID];
                CurrentArrayValuesParsed = arrayValuesParsed[CurrentParameterID];
                currentArrayIDEdited     = CurrentArrayTextEntered.Count - 1;
                if (CurrentArrayIDEdited >= 0)
                {
                    CurrentTextEntered = CurrentArrayTextEntered[CurrentArrayIDEdited];
                }
            }
            else
            {
                CurrentTextEntered = TextEntered[CurrentParameterID];
            }

            if (!CurrentTextEntered.IsNullOrEmpty())
            {
                RegenerateAutoComplete();
            }
            else
            {
                CurrentAutoComplete?.InitializeAutoComplete();
            }

            CommandConsoleWindow.CurrentPanel.SearchTerms         = CurrentTextEntered;
            CommandConsoleWindow.CurrentPanel.PreviousSearchTerms = CurrentTextEntered;
        }