From d8f910f8e668184f4cebee76a2750ef9f28e9971 Mon Sep 17 00:00:00 2001 From: Andrew Carney Date: Thu, 24 Mar 2022 22:48:30 -0400 Subject: [PATCH] Convert public method collection parameters to interfaces. --- TwitchLib.Api.Core.Interfaces/IApiSettings.cs | 2 +- TwitchLib.Api.Core/ApiSettings.cs | 4 ++-- TwitchLib.Api.Helix/ChannelPoints.cs | 2 +- TwitchLib.Api.Helix/Clips.cs | 2 +- TwitchLib.Api.Helix/Entitlements.cs | 4 ++-- TwitchLib.Api.Helix/EventSub.cs | 2 +- TwitchLib.Api.Helix/Extensions.cs | 2 +- TwitchLib.Api.Helix/Games.cs | 2 +- TwitchLib.Api.Helix/Moderation.cs | 12 ++++++------ TwitchLib.Api.Helix/Polls.cs | 2 +- TwitchLib.Api.Helix/Predictions.cs | 2 +- TwitchLib.Api.Helix/Schedule.cs | 2 +- TwitchLib.Api.Helix/Streams.cs | 4 ++-- TwitchLib.Api.Helix/Subscriptions.cs | 2 +- TwitchLib.Api.Helix/Users.cs | 2 +- TwitchLib.Api.Helix/Videos.cs | 2 +- .../Events/OnUserAuthorizationDetectedArgs.cs | 2 +- TwitchLib.Api/Services/ApiService.cs | 8 ++++---- .../Services/Core/LiveStreamMonitor/CoreMonitor.cs | 2 +- .../Core/LiveStreamMonitor/IdBasedMonitor.cs | 2 +- .../Core/LiveStreamMonitor/NameBasedMonitor.cs | 2 +- .../FollowerService/OnNewFollowersDetectedArgs.cs | 2 +- TwitchLib.Api/Services/Events/OnChannelsSetArgs.cs | 2 +- TwitchLib.Api/Services/FollowerService.cs | 12 ++++++------ TwitchLib.Api/Services/LiveStreamMonitorService.cs | 4 ++-- 25 files changed, 42 insertions(+), 42 deletions(-) diff --git a/TwitchLib.Api.Core.Interfaces/IApiSettings.cs b/TwitchLib.Api.Core.Interfaces/IApiSettings.cs index 6aed6862..5dbdc1ae 100644 --- a/TwitchLib.Api.Core.Interfaces/IApiSettings.cs +++ b/TwitchLib.Api.Core.Interfaces/IApiSettings.cs @@ -11,7 +11,7 @@ public interface IApiSettings string ClientId { get; set; } bool SkipDynamicScopeValidation { get; set; } bool SkipAutoServerTokenGeneration { get; set; } - List Scopes { get; set; } + IList Scopes { get; set; } event PropertyChangedEventHandler PropertyChanged; } diff --git a/TwitchLib.Api.Core/ApiSettings.cs b/TwitchLib.Api.Core/ApiSettings.cs index 6c9e6ad3..1362048d 100644 --- a/TwitchLib.Api.Core/ApiSettings.cs +++ b/TwitchLib.Api.Core/ApiSettings.cs @@ -13,7 +13,7 @@ public class ApiSettings : IApiSettings, INotifyPropertyChanged private string _accessToken; private bool _skipDynamicScopeValidation; private bool _skipAutoServerTokenGeneration; - private List _scopes; + private IList _scopes; public string ClientId { get => _clientId; @@ -74,7 +74,7 @@ public bool SkipAutoServerTokenGeneration } } } - public List Scopes + public IList Scopes { get => _scopes; set diff --git a/TwitchLib.Api.Helix/ChannelPoints.cs b/TwitchLib.Api.Helix/ChannelPoints.cs index 3aa800a7..f8fd5fd9 100644 --- a/TwitchLib.Api.Helix/ChannelPoints.cs +++ b/TwitchLib.Api.Helix/ChannelPoints.cs @@ -45,7 +45,7 @@ public Task DeleteCustomRewardAsync(string broadcasterId, string rewardId, strin #endregion #region GetCustomReward - public Task GetCustomRewardAsync(string broadcasterId, List rewardIds = null, bool onlyManageableRewards = false, string accessToken = null) + public Task GetCustomRewardAsync(string broadcasterId, ICollection rewardIds = null, bool onlyManageableRewards = false, string accessToken = null) { var getParams = new List> { diff --git a/TwitchLib.Api.Helix/Clips.cs b/TwitchLib.Api.Helix/Clips.cs index 9a16c573..f42c80a3 100644 --- a/TwitchLib.Api.Helix/Clips.cs +++ b/TwitchLib.Api.Helix/Clips.cs @@ -19,7 +19,7 @@ public Clips(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandler h #region GetClips - public Task GetClipsAsync(List clipIds = null, string gameId = null, string broadcasterId = null, string before = null, string after = null, DateTime? startedAt = null, DateTime? endedAt = null, int first = 20, string accessToken = null) + public Task GetClipsAsync(IEnumerable clipIds = null, string gameId = null, string broadcasterId = null, string before = null, string after = null, DateTime? startedAt = null, DateTime? endedAt = null, int first = 20, string accessToken = null) { if (first < 0 || first > 100) throw new BadParameterException("'first' must between 0 (inclusive) and 100 (inclusive)."); diff --git a/TwitchLib.Api.Helix/Entitlements.cs b/TwitchLib.Api.Helix/Entitlements.cs index cefba430..292f2b42 100644 --- a/TwitchLib.Api.Helix/Entitlements.cs +++ b/TwitchLib.Api.Helix/Entitlements.cs @@ -19,7 +19,7 @@ public Entitlements(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHa } #region GetCodeStatus - public Task GetCodeStatusAsync(List codes, string userId, string accessToken = null) + public Task GetCodeStatusAsync(ICollection codes, string userId, string accessToken = null) { if (codes == null || codes.Count == 0 || codes.Count > 20) throw new BadParameterException("codes cannot be null and must ahve between 1 and 20 items"); @@ -83,7 +83,7 @@ public Task UpdateDropsEntitlementsAsync(string #endregion #region RedeemCode - public Task RedeemCodeAsync(List codes, string accessToken = null) + public Task RedeemCodeAsync(ICollection codes, string accessToken = null) { if (codes == null || codes.Count == 0 || codes.Count > 20) throw new BadParameterException("codes cannot be null and must ahve between 1 and 20 items"); diff --git a/TwitchLib.Api.Helix/EventSub.cs b/TwitchLib.Api.Helix/EventSub.cs index 1dc9d984..7abacd41 100644 --- a/TwitchLib.Api.Helix/EventSub.cs +++ b/TwitchLib.Api.Helix/EventSub.cs @@ -15,7 +15,7 @@ public EventSub(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandle { } - public Task CreateEventSubSubscriptionAsync(string type, string version, Dictionary condition, string method, string callback, + public Task CreateEventSubSubscriptionAsync(string type, string version, IDictionary condition, string method, string callback, string secret, string clientId = null, string accessToken = null) { if (string.IsNullOrEmpty(type)) diff --git a/TwitchLib.Api.Helix/Extensions.cs b/TwitchLib.Api.Helix/Extensions.cs index 638f0d17..e952fcfb 100644 --- a/TwitchLib.Api.Helix/Extensions.cs +++ b/TwitchLib.Api.Helix/Extensions.cs @@ -19,7 +19,7 @@ public Extensions(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHand #region GetExtensionTransactions - public Task GetExtensionTransactionsAsync(string extensionId, List ids = null, string after = null, int first = 20, string applicationAccessToken = null) + public Task GetExtensionTransactionsAsync(string extensionId, ICollection ids = null, string after = null, int first = 20, string applicationAccessToken = null) { if(extensionId == null) throw new BadParameterException("extensionId cannot be null"); diff --git a/TwitchLib.Api.Helix/Games.cs b/TwitchLib.Api.Helix/Games.cs index 91cb080f..058ce5a1 100644 --- a/TwitchLib.Api.Helix/Games.cs +++ b/TwitchLib.Api.Helix/Games.cs @@ -16,7 +16,7 @@ public Games(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandler h #region GetGames - public Task GetGamesAsync(List gameIds = null, List gameNames = null, string accessToken = null) + public Task GetGamesAsync(ICollection gameIds = null, ICollection gameNames = null, string accessToken = null) { if (gameIds == null && gameNames == null || gameIds != null && gameIds.Count == 0 && gameNames == null || gameNames != null && gameNames.Count == 0 && gameIds == null) throw new BadParameterException("Either gameIds or gameNames must have at least one value"); diff --git a/TwitchLib.Api.Helix/Moderation.cs b/TwitchLib.Api.Helix/Moderation.cs index 92718471..1f29ebb9 100644 --- a/TwitchLib.Api.Helix/Moderation.cs +++ b/TwitchLib.Api.Helix/Moderation.cs @@ -40,7 +40,7 @@ public Task ManageHeldAutoModMessagesAsync(string userId, string msgId, ManageHe #region CheckAutoModeStatus - public Task CheckAutoModStatusAsync(List messages, string broadcasterId, string accessToken = null) + public Task CheckAutoModStatusAsync(ICollection messages, string broadcasterId, string accessToken = null) { if (messages == null || messages.Count == 0) throw new BadParameterException("messages cannot be null and must be greater than 0 length"); @@ -55,7 +55,7 @@ public Task CheckAutoModStatusAsync(List me MessageRequest request = new MessageRequest() { - Messages = messages.ToArray() + Messages = (Message[])messages }; return TwitchPostGenericAsync("/moderation/enforcements/status", ApiVersion.Helix, JsonConvert.SerializeObject(request), getParams, accessToken); @@ -65,7 +65,7 @@ public Task CheckAutoModStatusAsync(List me #region GetBannedEvents - public Task GetBannedEventsAsync(string broadcasterId, List userIds = null, string after = null, string first = null, string accessToken = null) + public Task GetBannedEventsAsync(string broadcasterId, ICollection userIds = null, string after = null, string first = null, string accessToken = null) { if (broadcasterId == null || broadcasterId.Length == 0) throw new BadParameterException("broadcasterId cannot be null and must be greater than 0 length"); @@ -92,7 +92,7 @@ public Task GetBannedEventsAsync(string broadcasterId, #region GetBannedUsers - public Task GetBannedUsersAsync(string broadcasterId, List userIds = null, string after = null, string before = null, string accessToken = null) + public Task GetBannedUsersAsync(string broadcasterId, ICollection userIds = null, string after = null, string before = null, string accessToken = null) { if (broadcasterId == null || broadcasterId.Length == 0) throw new BadParameterException("broadcasterId cannot be null and must be greater than 0 length"); @@ -119,7 +119,7 @@ public Task GetBannedUsersAsync(string broadcasterId, Li #region GetModerators - public Task GetModeratorsAsync(string broadcasterId, List userIds = null, string after = null, string accessToken = null) + public Task GetModeratorsAsync(string broadcasterId, ICollection userIds = null, string after = null, string accessToken = null) { if (broadcasterId == null || broadcasterId.Length == 0) throw new BadParameterException("broadcasterId cannot be null and must be greater than 0 length"); @@ -143,7 +143,7 @@ public Task GetModeratorsAsync(string broadcasterId, List #region GetModeratorEvents - public Task GetModeratorEventsAsync(string broadcasterId, List userIds = null, string accessToken = null) + public Task GetModeratorEventsAsync(string broadcasterId, ICollection userIds = null, string accessToken = null) { if (broadcasterId == null || broadcasterId.Length == 0) throw new BadParameterException("broadcasterId cannot be null and must be greater than 0 length"); diff --git a/TwitchLib.Api.Helix/Polls.cs b/TwitchLib.Api.Helix/Polls.cs index ee26afdf..b984b559 100644 --- a/TwitchLib.Api.Helix/Polls.cs +++ b/TwitchLib.Api.Helix/Polls.cs @@ -19,7 +19,7 @@ public Polls(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandler h { } - public Task GetPollsAsync(string broadcasterId, List ids = null, string after = null, int first = 20, string accessToken = null) + public Task GetPollsAsync(string broadcasterId, ICollection ids = null, string after = null, int first = 20, string accessToken = null) { var getParams = new List> { diff --git a/TwitchLib.Api.Helix/Predictions.cs b/TwitchLib.Api.Helix/Predictions.cs index ed380633..39870e0f 100644 --- a/TwitchLib.Api.Helix/Predictions.cs +++ b/TwitchLib.Api.Helix/Predictions.cs @@ -19,7 +19,7 @@ public Predictions(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHan { } - public Task GetPredictionsAsync(string broadcasterId, List ids = null, string after = null, int first = 20, string accessToken = null) + public Task GetPredictionsAsync(string broadcasterId, ICollection ids = null, string after = null, int first = 20, string accessToken = null) { var getParams = new List> { diff --git a/TwitchLib.Api.Helix/Schedule.cs b/TwitchLib.Api.Helix/Schedule.cs index 4bbd1dba..0cc18c90 100644 --- a/TwitchLib.Api.Helix/Schedule.cs +++ b/TwitchLib.Api.Helix/Schedule.cs @@ -18,7 +18,7 @@ public class Schedule : ApiBase public Schedule(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandler http) : base(settings, rateLimiter, http) { } - public Task GetChannelStreamScheduleAsync(string broadcasterId, List segmentIds = null, string startTime = null, string utcOffset = null, + public Task GetChannelStreamScheduleAsync(string broadcasterId, ICollection segmentIds = null, string startTime = null, string utcOffset = null, int first = 20, string after = null, string accessToken = null) { var getParams = new List> diff --git a/TwitchLib.Api.Helix/Streams.cs b/TwitchLib.Api.Helix/Streams.cs index e734a71f..152fcd95 100644 --- a/TwitchLib.Api.Helix/Streams.cs +++ b/TwitchLib.Api.Helix/Streams.cs @@ -21,7 +21,7 @@ public Streams(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandler { } - public Task GetStreamsAsync(string after = null, List communityIds = null, int first = 20, List gameIds = null, List languages = null, string type = "all", List userIds = null, List userLogins = null, string accessToken = null) + public Task GetStreamsAsync(string after = null, ICollection communityIds = null, int first = 20, ICollection gameIds = null, ICollection languages = null, string type = "all", ICollection userIds = null, ICollection userLogins = null, string accessToken = null) { var getParams = new List> { @@ -76,7 +76,7 @@ public Task GetStreamTagsAsync(string broadcasterId, stri return TwitchGetGenericAsync("/streams/tags", ApiVersion.Helix, getParams, accessToken); } - public Task ReplaceStreamTagsAsync(string broadcasterId, List tagIds = null, string accessToken = null) + public Task ReplaceStreamTagsAsync(string broadcasterId, ICollection tagIds = null, string accessToken = null) { var getParams = new List>(); getParams.Add(new KeyValuePair("broadcaster_id", broadcasterId)); diff --git a/TwitchLib.Api.Helix/Subscriptions.cs b/TwitchLib.Api.Helix/Subscriptions.cs index 06f8d670..5cde73fe 100644 --- a/TwitchLib.Api.Helix/Subscriptions.cs +++ b/TwitchLib.Api.Helix/Subscriptions.cs @@ -31,7 +31,7 @@ public Task CheckUserSubscriptionAsync(string bro return TwitchGetGenericAsync("/subscriptions/user", ApiVersion.Helix, getParams, accessToken); } - public Task GetUserSubscriptionsAsync(string broadcasterId, List userIds, string accessToken = null) + public Task GetUserSubscriptionsAsync(string broadcasterId, ICollection userIds, string accessToken = null) { if (string.IsNullOrEmpty(broadcasterId)) { diff --git a/TwitchLib.Api.Helix/Users.cs b/TwitchLib.Api.Helix/Users.cs index 763b4306..cdbbf202 100644 --- a/TwitchLib.Api.Helix/Users.cs +++ b/TwitchLib.Api.Helix/Users.cs @@ -57,7 +57,7 @@ public Task UnblockUserAsync(string targetUserId, string accessToken = null) return TwitchDeleteAsync("/user/blocks", ApiVersion.Helix, getParams, accessToken); } - public Task GetUsersAsync(List ids = null, List logins = null, string accessToken = null) + public Task GetUsersAsync(ICollection ids = null, ICollection logins = null, string accessToken = null) { var getParams = new List>(); if (ids != null && ids.Count > 0) diff --git a/TwitchLib.Api.Helix/Videos.cs b/TwitchLib.Api.Helix/Videos.cs index 9ebb014f..907eb29b 100644 --- a/TwitchLib.Api.Helix/Videos.cs +++ b/TwitchLib.Api.Helix/Videos.cs @@ -28,7 +28,7 @@ public Task DeleteVideosAsync(List videoIds, strin return TwitchDeleteGenericAsync("/videos", ApiVersion.Helix, getParams, accessToken); } - public Task GetVideosAsync(List videoIds = null, string userId = null, string gameId = null, string after = null, string before = null, int first = 20, string language = null, Period period = Period.All, VideoSort sort = VideoSort.Time, VideoType type = VideoType.All, string accessToken = null) + public Task GetVideosAsync(ICollection videoIds = null, string userId = null, string gameId = null, string after = null, string before = null, int first = 20, string language = null, Period period = Period.All, VideoSort sort = VideoSort.Time, VideoType type = VideoType.All, string accessToken = null) { if ((videoIds == null || videoIds.Count == 0) && userId == null && gameId == null) throw new BadParameterException("VideoIds, userId, and gameId cannot all be null/empty."); diff --git a/TwitchLib.Api/Events/OnUserAuthorizationDetectedArgs.cs b/TwitchLib.Api/Events/OnUserAuthorizationDetectedArgs.cs index 141cf4a9..3b29ad1f 100644 --- a/TwitchLib.Api/Events/OnUserAuthorizationDetectedArgs.cs +++ b/TwitchLib.Api/Events/OnUserAuthorizationDetectedArgs.cs @@ -6,7 +6,7 @@ namespace TwitchLib.Api.Events public class OnUserAuthorizationDetectedArgs { public string Id { get; set; } - public List Scopes { get; set; } + public IList Scopes { get; set; } public string Username { get; set; } public string Token { get; set; } public string Refresh { get; set; } diff --git a/TwitchLib.Api/Services/ApiService.cs b/TwitchLib.Api/Services/ApiService.cs index da0f656f..349b4102 100644 --- a/TwitchLib.Api/Services/ApiService.cs +++ b/TwitchLib.Api/Services/ApiService.cs @@ -16,7 +16,7 @@ public class ApiService /// /// The list with channels to monitor. /// - public List ChannelsToMonitor { get; private set; } + public IList ChannelsToMonitor { get; private set; } /// /// How often the service is being updated in seconds. /// @@ -100,7 +100,7 @@ public virtual void Stop() /// When is null. /// When is empty. /// The channels to monitor. - protected virtual void SetChannels(List channelsToMonitor) + protected virtual void SetChannels(ICollection channelsToMonitor) { if (channelsToMonitor == null) throw new ArgumentNullException(nameof(channelsToMonitor)); @@ -108,9 +108,9 @@ protected virtual void SetChannels(List channelsToMonitor) if (channelsToMonitor.Count == 0) throw new ArgumentException("The provided list is empty.", nameof(channelsToMonitor)); - ChannelsToMonitor = channelsToMonitor; + ChannelsToMonitor = new List(channelsToMonitor); - OnChannelsSet?.Invoke(this, new OnChannelsSetArgs {Channels = channelsToMonitor}); + OnChannelsSet?.Invoke(this, new OnChannelsSetArgs {Channels = ChannelsToMonitor}); } /// diff --git a/TwitchLib.Api/Services/Core/LiveStreamMonitor/CoreMonitor.cs b/TwitchLib.Api/Services/Core/LiveStreamMonitor/CoreMonitor.cs index 2102de27..5a6c2eae 100644 --- a/TwitchLib.Api/Services/Core/LiveStreamMonitor/CoreMonitor.cs +++ b/TwitchLib.Api/Services/Core/LiveStreamMonitor/CoreMonitor.cs @@ -11,7 +11,7 @@ internal abstract class CoreMonitor { protected readonly ITwitchAPI _api; - public abstract Task GetStreamsAsync(List channels, string accessToken = null); + public abstract Task GetStreamsAsync(ICollection channels, string accessToken = null); public abstract Task> CompareStream(string channel, string accessToken = null); protected CoreMonitor(ITwitchAPI api) diff --git a/TwitchLib.Api/Services/Core/LiveStreamMonitor/IdBasedMonitor.cs b/TwitchLib.Api/Services/Core/LiveStreamMonitor/IdBasedMonitor.cs index fa80a36e..b61b1b12 100644 --- a/TwitchLib.Api/Services/Core/LiveStreamMonitor/IdBasedMonitor.cs +++ b/TwitchLib.Api/Services/Core/LiveStreamMonitor/IdBasedMonitor.cs @@ -16,7 +16,7 @@ public override Task> CompareStream(string channel, string ac return Task.FromResult(new Func(stream => stream.UserId == channel)); } - public override Task GetStreamsAsync(List channels, string accessToken = null) + public override Task GetStreamsAsync(ICollection channels, string accessToken = null) { return _api.Helix.Streams.GetStreamsAsync(first: channels.Count, userIds: channels, accessToken: accessToken); } diff --git a/TwitchLib.Api/Services/Core/LiveStreamMonitor/NameBasedMonitor.cs b/TwitchLib.Api/Services/Core/LiveStreamMonitor/NameBasedMonitor.cs index 102a919f..82ccbe8a 100644 --- a/TwitchLib.Api/Services/Core/LiveStreamMonitor/NameBasedMonitor.cs +++ b/TwitchLib.Api/Services/Core/LiveStreamMonitor/NameBasedMonitor.cs @@ -25,7 +25,7 @@ public override async Task> CompareStream(string channel, str return stream => stream.UserId == channelId; } - public override Task GetStreamsAsync(List channels, string accessToken = null) + public override Task GetStreamsAsync(ICollection channels, string accessToken = null) { return _api.Helix.Streams.GetStreamsAsync(first: channels.Count, userLogins: channels, accessToken: accessToken); } diff --git a/TwitchLib.Api/Services/Events/FollowerService/OnNewFollowersDetectedArgs.cs b/TwitchLib.Api/Services/Events/FollowerService/OnNewFollowersDetectedArgs.cs index 77d9bc8d..b43f9ea7 100644 --- a/TwitchLib.Api/Services/Events/FollowerService/OnNewFollowersDetectedArgs.cs +++ b/TwitchLib.Api/Services/Events/FollowerService/OnNewFollowersDetectedArgs.cs @@ -13,6 +13,6 @@ public class OnNewFollowersDetectedArgs : EventArgs /// Event property representing channel the service is currently monitoring. public string Channel; /// Event property representing all new followers detected. - public List NewFollowers; + public IList NewFollowers; } } diff --git a/TwitchLib.Api/Services/Events/OnChannelsSetArgs.cs b/TwitchLib.Api/Services/Events/OnChannelsSetArgs.cs index f1ca4d15..534fc5a2 100644 --- a/TwitchLib.Api/Services/Events/OnChannelsSetArgs.cs +++ b/TwitchLib.Api/Services/Events/OnChannelsSetArgs.cs @@ -12,6 +12,6 @@ public class OnChannelsSetArgs : EventArgs /// /// The channels the service is currently monitoring. /// - public List Channels; + public IList Channels; } } \ No newline at end of file diff --git a/TwitchLib.Api/Services/FollowerService.cs b/TwitchLib.Api/Services/FollowerService.cs index d272286d..ccc64f55 100644 --- a/TwitchLib.Api/Services/FollowerService.cs +++ b/TwitchLib.Api/Services/FollowerService.cs @@ -21,7 +21,7 @@ public class FollowerService : ApiService /// /// The current known followers for each channel. /// - public Dictionary> KnownFollowers { get; } = new Dictionary>(StringComparer.OrdinalIgnoreCase); + public IDictionary> KnownFollowers { get; } = new Dictionary>(StringComparer.OrdinalIgnoreCase); /// /// The amount of followers queried per request. /// @@ -84,7 +84,7 @@ public void ClearCache() /// When is null. /// When is empty. /// A list with channels to monitor. - public void SetChannelsById(List channelsToMonitor) + public void SetChannelsById(ICollection channelsToMonitor) { SetChannels(channelsToMonitor); @@ -97,7 +97,7 @@ public void SetChannelsById(List channelsToMonitor) /// When is null. /// When is empty. /// A list with channels to monitor. - public void SetChannelsByName(List channelsToMonitor) + public void SetChannelsByName(ICollection channelsToMonitor) { SetChannels(channelsToMonitor); @@ -115,7 +115,7 @@ public async Task UpdateLatestFollowersAsync(bool callEvents = true) foreach (var channel in ChannelsToMonitor) { - List newFollowers; + ICollection newFollowers; var latestFollowers = await GetLatestFollowersAsync(channel); if (latestFollowers.Count == 0) @@ -160,7 +160,7 @@ public async Task UpdateLatestFollowersAsync(bool callEvents = true) if (!callEvents) return; - OnNewFollowersDetected?.Invoke(this, new OnNewFollowersDetectedArgs { Channel = channel, NewFollowers = newFollowers }); + OnNewFollowersDetected?.Invoke(this, new OnNewFollowersDetectedArgs { Channel = channel, NewFollowers = newFollowers.ToList() }); } } @@ -170,7 +170,7 @@ protected override async Task OnServiceTimerTick() await UpdateLatestFollowersAsync(); } - private async Task> GetLatestFollowersAsync(string channel) + private async Task> GetLatestFollowersAsync(string channel) { var resultset = await _monitor.GetUsersFollowsAsync(channel, QueryCountPerRequest); diff --git a/TwitchLib.Api/Services/LiveStreamMonitorService.cs b/TwitchLib.Api/Services/LiveStreamMonitorService.cs index cd977a3d..84165449 100644 --- a/TwitchLib.Api/Services/LiveStreamMonitorService.cs +++ b/TwitchLib.Api/Services/LiveStreamMonitorService.cs @@ -18,7 +18,7 @@ public class LiveStreamMonitorService : ApiService /// /// A cache with streams that are currently live. /// - public Dictionary LiveStreams { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); + public IDictionary LiveStreams { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); /// /// The maximum amount of streams to collect per request. /// @@ -143,7 +143,7 @@ private void HandleOfflineStreamUpdate(string channel, bool callEvents) OnStreamOffline?.Invoke(this, new OnStreamOfflineArgs { Channel = channel, Stream = cachedLiveStream }); } - private async Task> GetLiveStreamersAsync() + private async Task> GetLiveStreamersAsync() { var livestreamers = new List(); var pages = Math.Ceiling((double)ChannelsToMonitor.Count / MaxStreamRequestCountPerRequest);