public static ChatCommandId FromType <T>() where T : IChatCommand { ChatCommandAttribute cacheableAttribute = (ChatCommandAttribute)AttributeUtilities.GetCacheableAttribute <T, ChatCommandAttribute>(); if (cacheableAttribute != null) { return(new ChatCommandId(cacheableAttribute.Name)); } return(new ChatCommandId((string)null)); }
public ChatCommandProcessor AddCommand <T>() where T : IChatCommand, new() { string commandKey = "ChatCommand." + ((ChatCommandAttribute)AttributeUtilities.GetCacheableAttribute <T, ChatCommandAttribute>()).Name; ChatCommandId index = ChatCommandId.FromType <T>(); this._commands[index] = (IChatCommand)Activator.CreateInstance <T>(); if (Language.Exists(commandKey)) { this._localizedCommands.Add(Language.GetText(commandKey), index); } else { commandKey += "_"; foreach (LocalizedText key in Language.FindAll((LanguageSearchFilter)((key, text) => key.StartsWith(commandKey)))) { this._localizedCommands.Add(key, index); } } return(this); }
public ChatCommandProcessor AddCommand <T>() where T : IChatCommand, new() { ChatCommandAttribute cacheableAttribute = AttributeUtilities.GetCacheableAttribute <T, ChatCommandAttribute>(); string commandKey = "ChatCommand." + cacheableAttribute.Name; ChatCommandId chatCommandId = ChatCommandId.FromType <T>(); _commands[chatCommandId] = new T(); if (Language.Exists(commandKey)) { _localizedCommands.Add(Language.GetText(commandKey), chatCommandId); } else { commandKey += "_"; LocalizedText[] array = Language.FindAll((string key, LocalizedText text) => key.StartsWith(commandKey)); foreach (LocalizedText key2 in array) { _localizedCommands.Add(key2, chatCommandId); } } return(this); }
// Token: 0x06001347 RID: 4935 RVA: 0x0041B370 File Offset: 0x00419570 public ChatCommandProcessor AddCommand <T>() where T : IChatCommand, new() { ChatCommandAttribute cacheableAttribute = AttributeUtilities.GetCacheableAttribute <T, ChatCommandAttribute>(); string commandKey = "ChatCommand." + cacheableAttribute.Name; ChatCommandId chatCommandId = ChatCommandId.FromType <T>(); this._commands[chatCommandId] = Activator.CreateInstance <T>(); if (Language.Exists(commandKey)) { this._localizedCommands.Add(Language.GetText(commandKey), chatCommandId); } else { commandKey += "_"; LocalizedText[] array = Language.FindAll((string key, LocalizedText text) => key.StartsWith(commandKey)); for (int i = 0; i < array.Length; i++) { LocalizedText key2 = array[i]; this._localizedCommands.Add(key2, chatCommandId); } } return(this); }
public ChatCommandProcessor AddCommand <T>() where T : IChatCommand, new() { var commandKey = "ChatCommand." + AttributeUtilities .GetCacheableAttribute <T, ChatCommandAttribute>().Name; var index = ChatCommandId.FromType <T>(); _commands[index] = new T(); if (Language.Exists(commandKey)) { _localizedCommands.Add(Language.GetText(commandKey), index); } else { commandKey += "_"; foreach (var key in Language.FindAll((key, text) => key.StartsWith(commandKey))) { _localizedCommands.Add(key, index); } } return(this); }