public T this[Snowflake parentId, Snowflake childId] { get { if (dictionary.TryGetValue(parentId, out ShardCacheDictionary <T> innerDictionary)) { if (innerDictionary.TryGetValue(childId, out T value)) { return(value); } } return(null); } set { ShardCacheDictionary <T> innerDictionary; if (!dictionary.TryGetValue(parentId, out innerDictionary)) { innerDictionary = new ShardCacheDictionary <T>(); dictionary[parentId] = innerDictionary; } innerDictionary[childId] = value; } }
public MutableGuild(Snowflake id, DiscordHttpClient http) : base(http) { Id = id; Features = new List <string>(); Emojis = new ShardCacheDictionary <DiscordEmoji>(); Roles = new ShardCacheDictionary <DiscordRole>(); }
public ShardCacheDictionary <T> GetOrCreateInner(Snowflake parentId) { ShardCacheDictionary <T> innerDictionary; if (!dictionary.TryGetValue(parentId, out innerDictionary)) { innerDictionary = new ShardCacheDictionary <T>(); dictionary[parentId] = innerDictionary; } return(innerDictionary); }
internal DiscordShardCache() { guildIds = new ConcurrentHashSet <Snowflake>(); unavailableGuildIds = new ConcurrentHashSet <Snowflake>(); GuildChannelIds = new ConcurrentDictionary <Snowflake, ConcurrentHashSet <Snowflake> >(); Users = new ShardCacheDictionary <MutableUser>(); DMChannels = new ShardCacheDictionary <MutableDMChannel>(); Guilds = new ShardCacheDictionary <MutableGuild>(); GuildMetadata = new ShardCacheDictionary <DiscordGuildMetadata>(); GuildChannels = new ShardCacheDictionary <DiscordGuildChannel>(); GuildMembers = new ShardNestedCacheDictionary <MutableGuildMember>(); GuildPresences = new ShardNestedCacheDictionary <DiscordUserPresence>(); GuildVoiceStates = new ShardNestedCacheDictionary <DiscordVoiceState>(); }