예제 #1
0
        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;
            }
        }
예제 #2
0
        public MutableGuild(Snowflake id, DiscordHttpClient http)
            : base(http)
        {
            Id = id;

            Features = new List <string>();

            Emojis = new ShardCacheDictionary <DiscordEmoji>();
            Roles  = new ShardCacheDictionary <DiscordRole>();
        }
예제 #3
0
        public ShardCacheDictionary <T> GetOrCreateInner(Snowflake parentId)
        {
            ShardCacheDictionary <T> innerDictionary;

            if (!dictionary.TryGetValue(parentId, out innerDictionary))
            {
                innerDictionary      = new ShardCacheDictionary <T>();
                dictionary[parentId] = innerDictionary;
            }

            return(innerDictionary);
        }
예제 #4
0
        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>();
        }