Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit 43d0ebb

Browse files
committed
Moved files around. Moved a few into the CodeFramework
1 parent e60edf1 commit 43d0ebb

18 files changed

+60
-84
lines changed

CodeHub.Core/App.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,29 @@ public override void Initialize()
1919
Cirrious.MvvmCross.Plugins.Messenger.PluginLoader.Instance.EnsureLoaded();
2020

2121
var httpService = Mvx.Resolve<IHttpClientService>();
22+
var jsonSerializerService = Mvx.Resolve<IJsonSerializationService>();
2223
GitHubSharp.Client.ClientConstructor = httpService.Create;
24+
GitHubSharp.Client.Serializer = new GitHubSharpSerializer(jsonSerializerService);
2325

2426
// Start the app with the First View Model.
2527
this.RegisterAppStart<StartupViewModel>();
2628
}
29+
30+
class GitHubSharpSerializer : GitHubSharp.ISerializer
31+
{
32+
readonly IJsonSerializationService _service;
33+
public GitHubSharpSerializer(IJsonSerializationService service)
34+
{
35+
this._service = service;
36+
}
37+
public string Serialize(object o)
38+
{
39+
return _service.Serialize(o);
40+
}
41+
public TData Deserialize<TData>(string data)
42+
{
43+
return _service.Deserialize<TData>(data);
44+
}
45+
}
2746
}
2847
}

CodeHub.Core/CodeHub.Core.iOS.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
<Compile Include="Services\IApplicationService.cs" />
4848
<Compile Include="Services\ILoginService.cs" />
4949
<Compile Include="Services\LoginService.cs" />
50-
<Compile Include="Utils\RepositoryIdentifier.cs" />
5150
<Compile Include="ViewModels\Accounts\AccountsViewModel.cs" />
5251
<Compile Include="ViewModels\Accounts\AddAccountViewModel.cs" />
5352
<Compile Include="ViewModels\App\SettingsViewModel.cs" />
@@ -102,7 +101,6 @@
102101
<Compile Include="ViewModels\Gists\GistFileViewModel.cs" />
103102
<Compile Include="Utils\ViewModelExtensions.cs" />
104103
<Compile Include="ViewModels\Source\ChangesetDiffViewModel.cs" />
105-
<Compile Include="Services\JsonSerializationService.cs" />
106104
<Compile Include="ViewModels\App\StartupViewModel.cs" />
107105
<Compile Include="Bootstrap\MessengerPluginBootstrap.cs" />
108106
<Compile Include="ViewModels\Issues\BaseIssuesViewModel.cs" />
@@ -117,7 +115,6 @@
117115
<Compile Include="Messages\IssueAddMessage.cs" />
118116
<Compile Include="ViewModels\Issues\IssueModifyViewModel.cs" />
119117
<Compile Include="Messages\IssueEditMessage.cs" />
120-
<Compile Include="Services\IMarkdownService.cs" />
121118
<Compile Include="ViewModels\App\DefaultStartupViewModel.cs" />
122119
<Compile Include="ViewModels\Accounts\LoginViewModel.cs" />
123120
<Compile Include="ViewModels\CommitsViewModel.cs" />
@@ -140,8 +137,8 @@
140137
<HintPath>..\lib\CodeFramework\lib\iOS\Cirrious.MvvmCross.Plugins.Messenger.dll</HintPath>
141138
</Reference>
142139
<Reference Include="System.Net.Http" />
143-
<Reference Include="Newtonsoft.Json">
144-
<HintPath>..\lib\GitHubSharp\lib\Newtonsoft.Json.dll</HintPath>
140+
<Reference Include="ServiceStack.Text.MonoTouch">
141+
<HintPath>..\lib\CodeFramework\lib\iOS\ServiceStack.Text.MonoTouch.dll</HintPath>
145142
</Reference>
146143
</ItemGroup>
147144
<ItemGroup>

CodeHub.Core/Services/GitHubAccountsService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class GitHubAccountsService : AccountsService<GitHubAccount>
99
public GitHubAccountsService(IDefaultValueService defaults, IAccountPreferencesService accountPreferences)
1010
: base(defaults, accountPreferences)
1111
{
12-
Console.WriteLine("Accounts created!");
1312
}
1413
}
1514
}

CodeHub.Core/Services/IMarkdownService.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

CodeHub.Core/Services/JsonSerializationService.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.

CodeHub.Core/Utils/RepositoryIdentifier.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

CodeHub.Core/ViewModels/App/MenuViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public ICommand GoToSettingsCommand
148148

149149
public ICommand GoToRepositoryCommand
150150
{
151-
get { return new MvxCommand<Utils.RepositoryIdentifier>(x => ShowMenuViewModel<RepositoryViewModel>(new RepositoryViewModel.NavObject { Username = x.Owner, Repository = x.Name }));}
151+
get { return new MvxCommand<RepositoryIdentifier>(x => ShowMenuViewModel<RepositoryViewModel>(new RepositoryViewModel.NavObject { Username = x.Owner, Repository = x.Name }));}
152152
}
153153

154154
public ICommand LoadCommand

CodeHub.Core/ViewModels/Events/BaseEventsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Windows.Input;
66
using Cirrious.MvvmCross.ViewModels;
77
using CodeFramework.Core.ViewModels;
8-
using CodeHub.Core.Utils;
98
using CodeHub.Core.ViewModels.Gists;
109
using CodeHub.Core.ViewModels.Issues;
1110
using CodeHub.Core.ViewModels.PullRequests;
@@ -14,6 +13,7 @@
1413
using CodeHub.Core.ViewModels.User;
1514
using GitHubSharp;
1615
using GitHubSharp.Models;
16+
using CodeFramework.Core.Utils;
1717

1818
namespace CodeHub.Core.ViewModels.Events
1919
{

CodeHub.Core/ViewModels/Issues/BaseIssuesViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using CodeHub.Core.Filters;
55
using System.Windows.Input;
66
using Cirrious.MvvmCross.ViewModels;
7-
using CodeHub.Core.Utils;
87
using CodeHub.Core.ViewModels.PullRequests;
98
using System.Collections.Generic;
109
using System.Linq;

CodeHub.Core/ViewModels/Issues/IssueEditViewModel.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,28 @@ protected override async Task Save()
4747
string[] labels = Labels.Items.Select(x => x.Name).ToArray();
4848
var content = Content ?? string.Empty;
4949
var state = IsOpen ? "open" : "closed";
50+
var retried = false;
5051

5152
IsSaving = true;
52-
var data = await this.GetApplication().Client.ExecuteAsync(this.GetApplication().Client.Users[Username].Repositories[Repository].Issues[Issue.Number].Update(Title, content, state, assignedTo, milestone, labels));
53-
Messenger.Publish(new IssueEditMessage(this) { Issue = data.Data });
53+
54+
// For some reason github needs to try again during an internal server error
55+
tryagain:
56+
57+
try
58+
{
59+
var data = await this.GetApplication().Client.ExecuteAsync(this.GetApplication().Client.Users[Username].Repositories[Repository].Issues[Issue.Number].Update(Title, content, state, assignedTo, milestone, labels));
60+
Messenger.Publish(new IssueEditMessage(this) { Issue = data.Data });
61+
}
62+
catch (GitHubSharp.InternalServerException)
63+
{
64+
if (retried)
65+
throw;
66+
67+
//Do nothing. Something is wrong with github's service
68+
retried = true;
69+
goto tryagain;
70+
}
71+
5472
ChangePresentation(new MvxClosePresentationHint(this));
5573
}
5674
catch (Exception e)

0 commit comments

Comments
 (0)