System.Collections.Generic.Dictionary.ContainsKey(VtuberInfo)

Here are the examples of the csharp api System.Collections.Generic.Dictionary.ContainsKey(VtuberInfo) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

19 Source : CacheManager.cs
with MIT License
from Mrs4s

private void TwitterCheckTimer()
        {
            foreach (var vtuber in Config.DefaultConfig.Vtubers.ToArray().Where(v => v.TwitterProfileId != null))
            {
                var timeline = TwitterApi.GetTimelineByUser(vtuber.TwitterProfileId, 10);
                if (!LastCheckTweets.ContainsKey(vtuber))
                    LastCheckTweets.Add(vtuber, timeline);
                LastCheckTweets[vtuber] = timeline;
                var lastRetweeted = timeline.FirstOrDefault(v => v.RetweetedTweet != null);
                var lastPublish = timeline.FirstOrDefault(v => v.RetweetedTweet == null && !v.IsReply && !v.IsQuote);
                var lastReply = timeline.FirstOrDefault(v => v.IsReply);
                //Update cache
                if (lastPublish != null)
                {
                    if (!LastTweetTime.ContainsKey(vtuber))
                        LastTweetTime.Add(vtuber, lastPublish.CreateTime);
                    if (LastTweetTime[vtuber] != lastPublish.CreateTime)
                    {
                        LastTweetTime[vtuber] = lastPublish.CreateTime;
                        VtuberPublishTweetEvent?.Invoke(vtuber, lastPublish);
                    }
                }

                if (lastReply != null)
                {
                    if (!LastReplyTime.ContainsKey(vtuber))
                        LastReplyTime.Add(vtuber, lastReply.CreateTime);
                    if (LastReplyTime[vtuber] != lastReply.CreateTime)
                    {
                        LastReplyTime[vtuber] = lastReply.CreateTime;
                        VtuberReplyTweetEvent?.Invoke(vtuber, lastReply);
                    }
                }

                if (lastRetweeted != null)
                {
                    if (!LastRetweetedTime.ContainsKey(vtuber))
                        LastRetweetedTime.Add(vtuber, lastRetweeted.CreateTime);
                    if (LastRetweetedTime[vtuber] != lastRetweeted.CreateTime)
                    {
                        LastRetweetedTime[vtuber] = lastRetweeted.CreateTime;
                        VtuberRetweetedEvent?.Invoke(vtuber, lastRetweeted);
                    }
                }
            }
        }

19 Source : CacheManager.cs
with MIT License
from Mrs4s

private void YoutubeVideoCheckTimer()
        {
            foreach (var vtuber in Config.DefaultConfig.Vtubers.ToArray().Where(v =>
                !string.IsNullOrEmpty(v.YoutubeChannelId) && string.IsNullOrEmpty(v.YoutubeUploadsPlaylistId)))
            {
                vtuber.YoutubeUploadsPlaylistId = YoutubeApi.GetUploadsPlaylistId(vtuber.YoutubeChannelId);
                Config.SaveToDefaultFile(Config.DefaultConfig);
                LogHelper.Info($"更新Vtuber {vtuber.OriginalName} Upload playlist id.");
            }
            foreach (var vtuber in Config.DefaultConfig.Vtubers.Where(v => !string.IsNullOrEmpty(v.YoutubeUploadsPlaylistId)))
            {
                var videos = YoutubeApi.GetPlaylisreplacedems(vtuber.YoutubeUploadsPlaylistId, 10);
                if (!LastCheckVideos.ContainsKey(vtuber))
                    LastCheckVideos.Add(vtuber, videos);
                if (LastCheckVideos[vtuber].FirstOrDefault()?.VideoId != videos.FirstOrDefault()?.VideoId)
                    VtuberUploadVideoEvent?.Invoke(vtuber, videos.First());
                LastCheckVideos[vtuber] = videos;
            }
        }

19 Source : CacheManager.cs
with MIT License
from Mrs4s

private void YoutubeLiveCheckTimer(List<VtuberInfo> vtubers)
        {
            foreach (var vtuber in vtubers)
            {
                if (!LastCheckLiveStatus.ContainsKey(vtuber))
                    LastCheckLiveStatus.Add(vtuber, new YoutubeVideo());
                var nowLive = YoutubeApi.NowLive(vtuber.YoutubeChannelId);;
                if (nowLive && !LastCheckLiveStatus[vtuber].IsLive)
                {
                    var live = YoutubeApi.GetVideosByChannelId(vtuber.YoutubeChannelId).FirstOrDefault(v => v.IsLive);
                    if (live == null)
                    {
                        var liveId = YoutubeApi.GetLiveVideoId(vtuber.YoutubeChannelId);
                        if (liveId == null)
                        {
                            LogHelper.Error("Error: liveId is null", false);
                            continue;
                        }
                        live = YoutubeApi.GetYoutubeVideo(liveId);
                        if (!live.IsLive)
                            continue;
                    }
                    if (!LastCheckLiveStatus[vtuber].IsLive)
                        VtuberBeginLiveEvent?.Invoke(vtuber, live);
                    LastCheckLiveStatus[vtuber] = live;
                }
                if (!nowLive)
                    LastCheckLiveStatus[vtuber] = new YoutubeVideo();
            }
        }

19 Source : CacheManager.cs
with MIT License
from Mrs4s

private void BilibiliLiveCheckTimer()
        {
            foreach (var vtuber in Config.DefaultConfig.Vtubers.Where(v => v.BilibiliUserId != default(long)))
            {
                var bUser = BiliBiliApi.GetBiliBiliUser(vtuber.BilibiliUserId);
                if (bUser != null)
                {
                    if (!LastCheckLiveBStatus.ContainsKey(vtuber))
                        LastCheckLiveBStatus.Add(vtuber, new BiliBiliUser());
                    if (!LastCheckLiveBStatus[vtuber].AreLive && bUser.AreLive)
                        VtuberBeginLiveBilibiliEvent?.Invoke(vtuber, bUser);
                    LastCheckLiveBStatus[vtuber] = bUser;
                }
            }
        }