From 68262a90c5971b8c6246f48c7ece361f5150d1aa Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Wed, 15 May 2024 04:12:25 +0900 Subject: [PATCH] =?utf8?q?ISocialAccount.AccountType=E3=83=97=E3=83=AD?= =?utf8?q?=E3=83=91=E3=83=86=E3=82=A3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- OpenTween.Tests/SocialProtocol/Twitter/TwitterAccountTest.cs | 7 +++++++ OpenTween/Models/DirectMessagesTabModel.cs | 2 +- OpenTween/Models/FavoritesTabModel.cs | 2 +- OpenTween/Models/ListTimelineTabModel.cs | 2 +- OpenTween/Models/MentionsTabModel.cs | 2 +- OpenTween/Models/PublicSearchTabModel.cs | 2 +- OpenTween/Models/RelatedPostsTabModel.cs | 2 +- OpenTween/Models/UserTimelineTabModel.cs | 2 +- OpenTween/SocialProtocol/ISocialAccount.cs | 2 ++ OpenTween/SocialProtocol/Twitter/TwitterAccount.cs | 3 +++ 10 files changed, 19 insertions(+), 7 deletions(-) diff --git a/OpenTween.Tests/SocialProtocol/Twitter/TwitterAccountTest.cs b/OpenTween.Tests/SocialProtocol/Twitter/TwitterAccountTest.cs index 0bd65e11..043543dd 100644 --- a/OpenTween.Tests/SocialProtocol/Twitter/TwitterAccountTest.cs +++ b/OpenTween.Tests/SocialProtocol/Twitter/TwitterAccountTest.cs @@ -83,6 +83,13 @@ namespace OpenTween.SocialProtocol.Twitter } [Fact] + public void AccountType_Test() + { + using var account = new TwitterAccount(Guid.NewGuid()); + Assert.Equal("Twitter", account.AccountType); + } + + [Fact] public void Client_V1_Test() { var accountKey = Guid.NewGuid(); diff --git a/OpenTween/Models/DirectMessagesTabModel.cs b/OpenTween/Models/DirectMessagesTabModel.cs index c9e0d435..6527e5a7 100644 --- a/OpenTween/Models/DirectMessagesTabModel.cs +++ b/OpenTween/Models/DirectMessagesTabModel.cs @@ -58,7 +58,7 @@ namespace OpenTween.Models public override async Task RefreshAsync(ISocialAccount account, bool backward, IProgress progress) { if (account is not TwitterAccount twAccount) - throw new ArgumentException($"Invalid account type: {account.GetType()}", nameof(account)); + throw new ArgumentException($"Invalid account type: {account.AccountType}", nameof(account)); progress.Report(string.Format(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText8, backward ? -1 : 1)); diff --git a/OpenTween/Models/FavoritesTabModel.cs b/OpenTween/Models/FavoritesTabModel.cs index 08ad99b4..f8889e00 100644 --- a/OpenTween/Models/FavoritesTabModel.cs +++ b/OpenTween/Models/FavoritesTabModel.cs @@ -56,7 +56,7 @@ namespace OpenTween.Models public override async Task RefreshAsync(ISocialAccount account, bool backward, IProgress progress) { if (account is not TwitterAccount twAccount) - throw new ArgumentException($"Invalid account type: {account.GetType()}", nameof(account)); + throw new ArgumentException($"Invalid account type: {account.AccountType}", nameof(account)); progress.Report(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText19); diff --git a/OpenTween/Models/ListTimelineTabModel.cs b/OpenTween/Models/ListTimelineTabModel.cs index d476b563..f95918b2 100644 --- a/OpenTween/Models/ListTimelineTabModel.cs +++ b/OpenTween/Models/ListTimelineTabModel.cs @@ -54,7 +54,7 @@ namespace OpenTween.Models public override async Task RefreshAsync(ISocialAccount account, bool backward, IProgress progress) { if (account is not TwitterAccount twAccount) - throw new ArgumentException($"Invalid account type: {account.GetType()}", nameof(account)); + throw new ArgumentException($"Invalid account type: {account.AccountType}", nameof(account)); if (this.ListInfo == null || this.ListInfo.Id == 0) return; diff --git a/OpenTween/Models/MentionsTabModel.cs b/OpenTween/Models/MentionsTabModel.cs index ab099dcc..b44d9347 100644 --- a/OpenTween/Models/MentionsTabModel.cs +++ b/OpenTween/Models/MentionsTabModel.cs @@ -56,7 +56,7 @@ namespace OpenTween.Models public override async Task RefreshAsync(ISocialAccount account, bool backward, IProgress progress) { if (account is not TwitterAccount twAccount) - throw new ArgumentException($"Invalid account type: {account.GetType()}", nameof(account)); + throw new ArgumentException($"Invalid account type: {account.AccountType}", nameof(account)); progress.Report(string.Format(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText4, backward ? -1 : 1)); diff --git a/OpenTween/Models/PublicSearchTabModel.cs b/OpenTween/Models/PublicSearchTabModel.cs index 0ae9d1b4..269f91be 100644 --- a/OpenTween/Models/PublicSearchTabModel.cs +++ b/OpenTween/Models/PublicSearchTabModel.cs @@ -74,7 +74,7 @@ namespace OpenTween.Models public override async Task RefreshAsync(ISocialAccount account, bool backward, IProgress progress) { if (account is not TwitterAccount twAccount) - throw new ArgumentException($"Invalid account type: {account.GetType()}", nameof(account)); + throw new ArgumentException($"Invalid account type: {account.AccountType}", nameof(account)); if (MyCommon.IsNullOrEmpty(this.SearchWords)) return; diff --git a/OpenTween/Models/RelatedPostsTabModel.cs b/OpenTween/Models/RelatedPostsTabModel.cs index 7bf99b68..3882855b 100644 --- a/OpenTween/Models/RelatedPostsTabModel.cs +++ b/OpenTween/Models/RelatedPostsTabModel.cs @@ -59,7 +59,7 @@ namespace OpenTween.Models public override async Task RefreshAsync(ISocialAccount account, bool backward, IProgress progress) { if (account is not TwitterAccount twAccount) - throw new ArgumentException($"Invalid account type: {account.GetType()}", nameof(account)); + throw new ArgumentException($"Invalid account type: {account.AccountType}", nameof(account)); try { diff --git a/OpenTween/Models/UserTimelineTabModel.cs b/OpenTween/Models/UserTimelineTabModel.cs index 1a3095d0..0c13c613 100644 --- a/OpenTween/Models/UserTimelineTabModel.cs +++ b/OpenTween/Models/UserTimelineTabModel.cs @@ -56,7 +56,7 @@ namespace OpenTween.Models public override async Task RefreshAsync(ISocialAccount account, bool backward, IProgress progress) { if (account is not TwitterAccount twAccount) - throw new ArgumentException($"Invalid account type: {account.GetType()}", nameof(account)); + throw new ArgumentException($"Invalid account type: {account.AccountType}", nameof(account)); if (MyCommon.IsNullOrEmpty(this.ScreenName)) return; diff --git a/OpenTween/SocialProtocol/ISocialAccount.cs b/OpenTween/SocialProtocol/ISocialAccount.cs index d1a14b85..7c92acd3 100644 --- a/OpenTween/SocialProtocol/ISocialAccount.cs +++ b/OpenTween/SocialProtocol/ISocialAccount.cs @@ -28,6 +28,8 @@ namespace OpenTween.SocialProtocol { public interface ISocialAccount : IDisposable { + public string AccountType { get; } + public Guid UniqueKey { get; } public long UserId { get; } diff --git a/OpenTween/SocialProtocol/Twitter/TwitterAccount.cs b/OpenTween/SocialProtocol/Twitter/TwitterAccount.cs index 0f7f1d4d..12731d88 100644 --- a/OpenTween/SocialProtocol/Twitter/TwitterAccount.cs +++ b/OpenTween/SocialProtocol/Twitter/TwitterAccount.cs @@ -32,6 +32,9 @@ namespace OpenTween.SocialProtocol.Twitter private readonly OpenTween.Twitter twLegacy = new(new()); private TwitterApiConnection apiConnection = new(); + public string AccountType + => "Twitter"; + public Guid UniqueKey { get; } public ISocialProtocolClient Client { get; private set; } -- 2.11.0