Ejemplo n.º 1
0
        public override IEnumerator <string> Complete(CommandDispatcher dispatcher, string partialCommand, string lastWord)
        {
            IEnumerator <string> complete = null;

            SortedList <string, string> commands = new SortedList <string, string>();

            commands.Add("analytics", "");
            commands.Add("free", "");
            commands.Add("network", "");
            commands.Add("paths", "");
            commands.Add("status", "");

            string[] sp = partialCommand.Trim().Split(' ');
            if (sp.Length >= 1 && String.Compare(sp[0], "show", StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (lastWord.Length > 0)
                {
                    complete = SubsetCollection <string> .Tail(commands, lastWord).GetEnumerator();
                }
                else
                {
                    complete = commands.Keys.GetEnumerator();
                }
            }

            return(complete);
        }
Ejemplo n.º 2
0
 public PriorityVisitor(
     SubsetCollection <string> subsets,
     HashSet <string> metadataAttributes)
 {
     _subsets            = subsets ?? throw new ArgumentNullException(nameof(subsets));
     _metadataAttributes = metadataAttributes ??
                           throw new ArgumentNullException(nameof(metadataAttributes));
 }
Ejemplo n.º 3
0
        public IEnumerator <string> GetAlternatives(string partialName)
        {
            // first test, if we find the name directly
            IEnumerator <string> testIt = SubsetCollection <string> .Tail(nameSet, partialName).GetEnumerator();

            string testMatch = (testIt.MoveNext()) ? (string)testIt.Current : null;

            if (testMatch == null || !testMatch.StartsWith(partialName))
            {
                string canonical = partialName.ToLower();
                testIt = SubsetDictionary <string, string> .Tail(canonicalNames, canonical).Keys.GetEnumerator();

                testMatch = (testIt.MoveNext()) ? (string)testIt.Current : null;
                if (testMatch == null || !testMatch.StartsWith(canonical))
                {
                    return(null);                    // nope.
                }
                string foundName = (string)canonicalNames[testMatch];
                partialName = foundName.Substring(0, partialName.Length);
            }

            return(new NameEnumerator(this, partialName));
        }
Ejemplo n.º 4
0
            public NameEnumerator(NameCompleter completer, string partialName)
            {
                enumerator = SubsetCollection <string> .Tail(completer.nameSet, partialName).GetEnumerator();

                namePattern = partialName;
            }