private static void RetrieveCommandsArgs(out HashSet <string> toFill, IEnumerable <KeyValuePair <string, AutoCompletionAttribute[]> > commands)
        {
            toFill = new HashSet <string>();

            foreach (var command in commands)
            {
                var commandName = command.Key;
                var acAttribute = command.Value;

                foreach (var attribute in acAttribute)
                {
                    foreach (object item in attribute.Catalog)
                    {
                        string itemString = "";
                        if (attribute.NestedField != string.Empty)
                        {
                            var    block = attribute.NestedField.Split('/');
                            object tmp   = null;
                            for (int i = 0; i < block.Length; i++)
                            {
                                if (tmp == null)
                                {
                                    tmp = item.GetFieldValue <object>(block[i]);
                                }
                                else
                                {
                                    tmp = tmp.GetFieldValue <object>(block[i]);
                                }
                            }

                            if (tmp != null)
                            {
                                itemString = tmp.ToString();
                            }
                        }
                        else
                        {
                            itemString = item.ToString();
                        }


                        if (itemString.Contains(" "))
                        {
                            itemString = itemString.Substring(0, itemString.IndexOf(' '));
                            toFill.Add(commandName + itemString);
                        }
                        else
                        {
                            toFill.Add(commandName + itemString);
                        }

                        if (attribute.NestedField != string.Empty)
                        {
                            continue;
                        }

                        var languageDictionaries = typeof(Language).GetFieldValue <Dictionary <string, Dictionary <string, string> > >("languageDictionaries");
                        if (languageDictionaries.TryGetValue(Language.currentLanguage, out var dictionary))
                        {
                            foreach (var tokenAndInvar in dictionary)
                            {
                                if (tokenAndInvar.Key.Contains(itemString.ToUpper()) &&
                                    tokenAndInvar.Key.Contains("NAME"))
                                {
                                    if (!tokenAndInvar.Value.Contains("NAME"))
                                    {
                                        toFill.Add(commandName + Alias.RemoveSpacesAndAlike(tokenAndInvar.Value));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#2
0
 private static void CCGetTeamIndexPartial(ConCommandArgs args)
 {
     //Alias.Instance.GetMasterName(args[0]);
     Log.Message(Alias.GetEnumFromPartial <TeamIndex>(args[0]).ToString());
 }