Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit e2b74f9

Browse files
committed
Remove interfaces from Remote/RepositoryModel
RepositoryModel and RemoteRepositoryModel are now pure models without interfaces.
1 parent a1ff038 commit e2b74f9

File tree

54 files changed

+143
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+143
-231
lines changed

src/GitHub.App/SampleData/Dialog/Clone/SelectPageViewModelDesigner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public SelectPageViewModelDesigner()
3838
public IReadOnlyList<IRepositoryItemViewModel> Items { get; }
3939
public ICollectionView ItemsView { get; }
4040
public IRepositoryItemViewModel SelectedItem { get; set; }
41-
public IRepositoryModel Repository { get; }
41+
public RepositoryModel Repository { get; }
4242

4343
public void Initialize(IConnection connection)
4444
{

src/GitHub.App/SampleData/ForkRepositoryExecuteViewModelDesigner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public ForkRepositoryExecuteViewModelDesigner()
3535

3636
public string Title => null;
3737

38-
public IRepositoryModel SourceRepository { get; set; }
38+
public RepositoryModel SourceRepository { get; set; }
3939

40-
public IRepositoryModel DestinationRepository { get; set; }
40+
public RepositoryModel DestinationRepository { get; set; }
4141

4242
public IAccount DestinationAccount { get; }
4343

src/GitHub.App/SampleData/ForkRepositorySelectViewModelDesigner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public ForkRepositorySelectViewModelDesigner()
3333

3434
public IObservable<object> Done => null;
3535

36-
public IReadOnlyList<IRemoteRepositoryModel> ExistingForks { get; set; }
36+
public IReadOnlyList<RemoteRepositoryModel> ExistingForks { get; set; }
3737

3838
public bool IsLoading { get; set; }
3939

4040
public string Title => null;
4141

4242
public ReactiveCommand<IAccount, Unit> SelectedAccount => null;
4343

44-
public ReactiveCommand<IRemoteRepositoryModel, Unit> SwitchOrigin => null;
44+
public ReactiveCommand<RemoteRepositoryModel, Unit> SwitchOrigin => null;
4545

4646
public Task InitializeAsync(LocalRepositoryModel repository, IConnection connection)
4747
{

src/GitHub.App/SampleData/ForkRepositorySwitchViewModelDesigner.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public ForkRepositorySwitchViewModelDesigner()
2929

3030
public IObservable<object> Done => null;
3131

32-
public IRepositoryModel SourceRepository { get; }
32+
public RepositoryModel SourceRepository { get; }
3333

34-
public IRepositoryModel DestinationRepository { get; }
34+
public RepositoryModel DestinationRepository { get; }
3535

3636
public ReactiveCommand<Unit, Unit> SwitchFork => null;
3737

@@ -41,7 +41,7 @@ public ForkRepositorySwitchViewModelDesigner()
4141

4242
public bool UpdateOrigin { get; set; } = true;
4343

44-
public void Initialize(LocalRepositoryModel sourceRepository, IRemoteRepositoryModel remoteRepository)
44+
public void Initialize(LocalRepositoryModel sourceRepository, RemoteRepositoryModel remoteRepository)
4545
{
4646
}
4747
}

src/GitHub.App/SampleData/PullRequestListViewModelDesigner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public PullRequestListViewModelDesigner()
5555
public ICollectionView ItemsView { get; }
5656
public LocalRepositoryModel LocalRepository { get; set; }
5757
public IssueListMessage Message { get; set; }
58-
public IRepositoryModel RemoteRepository { get; set; }
59-
public IReadOnlyList<IRepositoryModel> Forks { get; }
58+
public RepositoryModel RemoteRepository { get; set; }
59+
public IReadOnlyList<RepositoryModel> Forks { get; }
6060
public string SearchQuery { get; set; }
6161
public string SelectedState { get; set; }
6262
public string StateCaption { get; set; }

src/GitHub.App/SampleData/RemoteRepositoryModelDesigner.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace GitHub.SampleData
77
{
88
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1036:OverrideMethodsOnComparableTypes")]
9-
public class RemoteRepositoryModelDesigner : IRemoteRepositoryModel
9+
public class RemoteRepositoryModelDesigner : RemoteRepositoryModel
1010
{
1111
public UriString CloneUrl { get; set; }
1212
public DateTimeOffset CreatedAt { get; set; }
@@ -17,20 +17,20 @@ public class RemoteRepositoryModelDesigner : IRemoteRepositoryModel
1717
public string Name { get; set; }
1818
public string Owner { get; set; }
1919
public IAccount OwnerAccount { get; set; }
20-
public IRemoteRepositoryModel Parent { get; set; }
20+
public RemoteRepositoryModel Parent { get; set; }
2121
public DateTimeOffset UpdatedAt { get; set; }
2222

23-
public int CompareTo(IRemoteRepositoryModel other)
23+
public int CompareTo(RemoteRepositoryModel other)
2424
{
2525
return 0;
2626
}
2727

28-
public void CopyFrom(IRemoteRepositoryModel other)
28+
public void CopyFrom(RemoteRepositoryModel other)
2929
{
3030
}
3131

3232
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
33-
public bool Equals(IRemoteRepositoryModel other)
33+
public bool Equals(RemoteRepositoryModel other)
3434
{
3535
return false;
3636
}

src/GitHub.App/SampleData/RepositoryRecloneViewModelDesigner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class RepositoryRecloneViewModelDesigner : ViewModelBase, IRepositoryRecl
1717
public ReactivePropertyValidator<string> BaseRepositoryPathValidator { get; }
1818
public ICommand BrowseForDirectory { get; }
1919
public ReactiveCommand<Unit, Unit> CloneCommand { get; }
20-
public IRepositoryModel SelectedRepository { get; set; }
20+
public RepositoryModel SelectedRepository { get; set; }
2121
public IObservable<object> Done { get; }
2222

2323
public Task InitializeAsync(IConnection connection) => Task.CompletedTask;

src/GitHub.App/SampleData/SampleViewModels.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public IConnection SelectedConnection
254254
[ExcludeFromCodeCoverage]
255255
public static class RepositoryModelDesigner
256256
{
257-
public static IRemoteRepositoryModel Create(string name = null, string owner = null)
257+
public static RemoteRepositoryModel Create(string name = null, string owner = null)
258258
{
259259
name = name ?? "octocat";
260260
owner = owner ?? "github";

src/GitHub.App/Services/DialogService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public async Task<CloneDialogResult> ShowCloneDialog(IConnection connection, str
5252
}
5353
}
5454

55-
public async Task<string> ShowReCloneDialog(IRepositoryModel repository)
55+
public async Task<string> ShowReCloneDialog(RepositoryModel repository)
5656
{
5757
Guard.ArgumentNotNull(repository, nameof(repository));
5858

src/GitHub.App/Services/ModelService.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public IObservable<IReadOnlyList<IAccount>> GetAccounts()
104104
.ToReadOnlyList(Create);
105105
}
106106

107-
public IObservable<IRemoteRepositoryModel> GetForks(IRepositoryModel repository)
107+
public IObservable<RemoteRepositoryModel> GetForks(RepositoryModel repository)
108108
{
109109
return ApiClient.GetForks(repository.Owner, repository.Name)
110110
.Select(x => new RemoteRepositoryModel(x));
@@ -156,7 +156,7 @@ IObservable<IEnumerable<AccountCacheItem>> GetUserOrganizations()
156156
});
157157
}
158158

159-
public IObservable<IReadOnlyList<IRemoteRepositoryModel>> GetRepositories()
159+
public IObservable<IReadOnlyList<RemoteRepositoryModel>> GetRepositories()
160160
{
161161
return GetUserRepositories(RepositoryType.Owner)
162162
.TakeLast(1)
@@ -175,7 +175,7 @@ IObservable<AccountCacheItem> GetUserFromCache()
175175
/// <param name="repo"></param>
176176
/// <param name="collection"></param>
177177
/// <returns></returns>
178-
public ITrackingCollection<IPullRequestModel> GetPullRequests(IRepositoryModel repo,
178+
public ITrackingCollection<IPullRequestModel> GetPullRequests(RepositoryModel repo,
179179
ITrackingCollection<IPullRequestModel> collection)
180180
{
181181
// Since the api to list pull requests returns all the data for each pr, cache each pr in its own entry
@@ -215,7 +215,7 @@ public IObservable<IPullRequestModel> GetPullRequest(string owner, string name,
215215
throw new NotImplementedException();
216216
}
217217

218-
public IObservable<IRemoteRepositoryModel> GetRepository(string owner, string repo)
218+
public IObservable<RemoteRepositoryModel> GetRepository(string owner, string repo)
219219
{
220220
var keyobs = GetUserFromCache()
221221
.Select(user => string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}/{3}", CacheIndex.RepoPrefix, user.Login, owner, repo));
@@ -228,7 +228,7 @@ public IObservable<IRemoteRepositoryModel> GetRepository(string owner, string re
228228
.Select(Create)));
229229
}
230230

231-
public ITrackingCollection<IRemoteRepositoryModel> GetRepositories(ITrackingCollection<IRemoteRepositoryModel> collection)
231+
public ITrackingCollection<RemoteRepositoryModel> GetRepositories(ITrackingCollection<RemoteRepositoryModel> collection)
232232
{
233233
var keyobs = GetUserFromCache()
234234
.Select(user => string.Format(CultureInfo.InvariantCulture, "{0}|{1}", CacheIndex.RepoPrefix, user.Login));
@@ -256,7 +256,7 @@ public ITrackingCollection<IRemoteRepositoryModel> GetRepositories(ITrackingColl
256256
return collection;
257257
}
258258

259-
public IObservable<IPullRequestModel> CreatePullRequest(LocalRepositoryModel sourceRepository, IRepositoryModel targetRepository,
259+
public IObservable<IPullRequestModel> CreatePullRequest(LocalRepositoryModel sourceRepository, RepositoryModel targetRepository,
260260
BranchModel sourceBranch, BranchModel targetBranch,
261261
string title, string body)
262262
{
@@ -286,7 +286,7 @@ public IObservable<Unit> InvalidateAll()
286286
return hostCache.InvalidateAll().ContinueAfter(() => hostCache.Vacuum());
287287
}
288288

289-
public IObservable<string> GetFileContents(IRepositoryModel repo, string commitSha, string path, string fileSha)
289+
public IObservable<string> GetFileContents(RepositoryModel repo, string commitSha, string path, string fileSha)
290290
{
291291
return Observable.Defer(() => Task.Run(async () =>
292292
{
@@ -305,22 +305,22 @@ public IObservable<string> GetFileContents(IRepositoryModel repo, string commitS
305305
}));
306306
}
307307

308-
IObservable<IReadOnlyList<IRemoteRepositoryModel>> GetUserRepositories(RepositoryType repositoryType)
308+
IObservable<IReadOnlyList<RemoteRepositoryModel>> GetUserRepositories(RepositoryType repositoryType)
309309
{
310310
return Observable.Defer(() => GetUserFromCache().SelectMany(user =>
311311
hostCache.GetAndRefreshObject(string.Format(CultureInfo.InvariantCulture, "{0}|{1}:repos", user.Login, repositoryType),
312312
() => GetUserRepositoriesFromApi(repositoryType),
313313
TimeSpan.FromMinutes(2),
314314
TimeSpan.FromDays(7)))
315315
.ToReadOnlyList(Create))
316-
.Catch<IReadOnlyList<IRemoteRepositoryModel>, KeyNotFoundException>(
316+
.Catch<IReadOnlyList<RemoteRepositoryModel>, KeyNotFoundException>(
317317
// This could in theory happen if we try to call this before the user is logged in.
318318
e =>
319319
{
320320
log.Error(e,
321321
"Retrieving {RepositoryType} user repositories failed because user is not stored in the cache",
322322
repositoryType);
323-
return Observable.Return(Array.Empty<IRemoteRepositoryModel>());
323+
return Observable.Return(Array.Empty<RemoteRepositoryModel>());
324324
});
325325
}
326326

@@ -333,14 +333,14 @@ IObservable<IEnumerable<RepositoryCacheItem>> GetUserRepositoriesFromApi(Reposit
333333
.Catch<IEnumerable<RepositoryCacheItem>, Exception>(_ => Observable.Return(Enumerable.Empty<RepositoryCacheItem>()));
334334
}
335335

336-
IObservable<IReadOnlyList<IRemoteRepositoryModel>> GetAllRepositoriesForAllOrganizations()
336+
IObservable<IReadOnlyList<RemoteRepositoryModel>> GetAllRepositoriesForAllOrganizations()
337337
{
338338
return GetUserOrganizations()
339339
.SelectMany(org => org.ToObservable())
340340
.SelectMany(org => GetOrganizationRepositories(org.Login).TakeLast(1));
341341
}
342342

343-
IObservable<IReadOnlyList<IRemoteRepositoryModel>> GetOrganizationRepositories(string organization)
343+
IObservable<IReadOnlyList<RemoteRepositoryModel>> GetOrganizationRepositories(string organization)
344344
{
345345
return Observable.Defer(() => GetUserFromCache().SelectMany(user =>
346346
hostCache.GetAndRefreshObject(string.Format(CultureInfo.InvariantCulture, "{0}|{1}|repos", user.Login, organization),
@@ -349,17 +349,17 @@ IObservable<IReadOnlyList<IRemoteRepositoryModel>> GetOrganizationRepositories(s
349349
TimeSpan.FromMinutes(2),
350350
TimeSpan.FromDays(7)))
351351
.ToReadOnlyList(Create))
352-
.Catch<IReadOnlyList<IRemoteRepositoryModel>, KeyNotFoundException>(
352+
.Catch<IReadOnlyList<RemoteRepositoryModel>, KeyNotFoundException>(
353353
// This could in theory happen if we try to call this before the user is logged in.
354354
e =>
355355
{
356356
log.Error(e, "Retrieveing {Organization} org repositories failed because user is not stored in the cache",
357357
organization);
358-
return Observable.Return(Array.Empty<IRemoteRepositoryModel>());
358+
return Observable.Return(Array.Empty<RemoteRepositoryModel>());
359359
});
360360
}
361361

362-
public IObservable<BranchModel> GetBranches(IRepositoryModel repo)
362+
public IObservable<BranchModel> GetBranches(RepositoryModel repo)
363363
{
364364
var keyobs = GetUserFromCache()
365365
.Select(user => string.Format(CultureInfo.InvariantCulture, "{0}|{1}|branch", user.Login, repo.Name));
@@ -403,7 +403,7 @@ IAccount Create(string login, string avatarUrl)
403403
avatarProvider.GetAvatar(avatarUrl));
404404
}
405405

406-
IRemoteRepositoryModel Create(RepositoryCacheItem item)
406+
RemoteRepositoryModel Create(RepositoryCacheItem item)
407407
{
408408
return new RemoteRepositoryModel(
409409
item.Id,

0 commit comments

Comments
 (0)