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

Commit 13fcd6f

Browse files
committed
Fully operational at 2.3.6
1 parent 24bf6e3 commit 13fcd6f

303 files changed

Lines changed: 25411 additions & 1057 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*/obj
33
*.suo
44
*.userprefs
5+
packages

CodeHub.Core/App.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Cirrious.MvvmCross.ViewModels;
1+
using Cirrious.MvvmCross.ViewModels;
22
using CodeHub.Core.ViewModels.App;
33
using CodeFramework.Core.Services;
44
using Cirrious.CrossCore;

CodeHub.Core/Cache/CacheEntry.cs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using SQLite;
2+
3+
namespace CodeFramework.Core.Cache
4+
{
5+
public class CacheEntry
6+
{
7+
[AutoIncrement]
8+
[PrimaryKey]
9+
public int Id { get; set; }
10+
11+
[Indexed]
12+
[MaxLength(1024)]
13+
public string Query { get; set; }
14+
15+
[MaxLength(1024)]
16+
public string Path { get; set; }
17+
18+
[MaxLength(256)]
19+
public string CacheTag { get; set; }
20+
21+
[Ignore]
22+
public bool IsValid
23+
{
24+
get
25+
{
26+
return System.IO.File.Exists(Path);
27+
}
28+
}
29+
30+
public bool Delete()
31+
{
32+
try
33+
{
34+
if (!IsValid) return false;
35+
System.IO.File.Delete(Path);
36+
return true;
37+
}
38+
catch
39+
{
40+
return false;
41+
}
42+
}
43+
44+
public byte[] LoadResult()
45+
{
46+
try
47+
{
48+
return System.IO.File.ReadAllBytes(Path);
49+
// using (var io = System.IO.File.OpenRead(Path))
50+
// {
51+
// var s = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
52+
// return (T)s.Deserialize(io);
53+
// }
54+
}
55+
catch (System.Exception e)
56+
{
57+
return null;
58+
}
59+
}
60+
61+
public void SaveResult(byte[] data)
62+
{
63+
System.IO.File.WriteAllBytes(Path, data);
64+
// using (var io = System.IO.File.OpenWrite(Path))
65+
// {
66+
// var s = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
67+
// s.Serialize(io, data);
68+
// }
69+
}
70+
}
71+
}
72+

CodeHub.Core/CodeHub.Core.iOS.csproj

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
86
<ProjectGuid>{B7970173-9022-466B-B57A-7AB1E1F3145F}</ProjectGuid>
9-
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
7+
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
108
<OutputType>Library</OutputType>
119
<RootNamespace>CodeHub.Core</RootNamespace>
1210
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
1311
<AssemblyName>CodeHub.Core</AssemblyName>
12+
<TargetFrameworkIdentifier>Xamarin.iOS</TargetFrameworkIdentifier>
13+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
1414
</PropertyGroup>
1515
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1616
<DebugSymbols>true</DebugSymbols>
@@ -135,38 +135,88 @@
135135
<Compile Include="ViewModels\Notifications\NotificationsViewModel.cs" />
136136
<Compile Include="ViewModels\LoadableViewModel.cs" />
137137
<Compile Include="Messages\PullRequestEditMessage.cs" />
138+
<Compile Include="Cache\CacheEntry.cs" />
139+
<Compile Include="Data\Account.cs" />
140+
<Compile Include="Data\AccountCache.cs" />
141+
<Compile Include="Data\AccountFilters.cs" />
142+
<Compile Include="Data\AccountPinnedRepositories.cs" />
143+
<Compile Include="Data\Filter.cs" />
144+
<Compile Include="Data\IAccount.cs" />
145+
<Compile Include="Data\PinnedRepository.cs" />
146+
<Compile Include="Data\SQLite.cs" />
147+
<Compile Include="Messages\CancelationMessage.cs" />
148+
<Compile Include="Messages\ErrorMessage.cs" />
149+
<Compile Include="Services\AccountsService.cs" />
150+
<Compile Include="Services\ErrorService.cs" />
151+
<Compile Include="Services\IAccountPreferencesService.cs" />
152+
<Compile Include="Services\IAccountsService.cs" />
153+
<Compile Include="Services\IAlertDialogService.cs" />
154+
<Compile Include="Services\IAnalyticsService.cs" />
155+
<Compile Include="Services\IDefaultValueService.cs" />
156+
<Compile Include="Services\IEnvrionmentService.cs" />
157+
<Compile Include="Services\IErrorService.cs" />
158+
<Compile Include="Services\IHttpClientService.cs" />
159+
<Compile Include="Services\IJsonHttpClientService.cs" />
160+
<Compile Include="Services\IJsonSerializationService.cs" />
161+
<Compile Include="Services\IShareService.cs" />
162+
<Compile Include="Services\IUIThreadService.cs" />
163+
<Compile Include="Services\IViewModelTxService.cs" />
164+
<Compile Include="Services\JsonHttpClientService.cs" />
165+
<Compile Include="Services\ViewModelTxService.cs" />
166+
<Compile Include="Utils\CrashReporting.cs" />
167+
<Compile Include="Utils\CustomObservableCollection.cs" />
168+
<Compile Include="Utils\DateTimeExtensions.cs" />
169+
<Compile Include="Utils\DefaultStartupViewCommand.cs" />
170+
<Compile Include="Utils\EnumExtensions.cs" />
171+
<Compile Include="Utils\ExceptionExtensions.cs" />
172+
<Compile Include="Utils\FilterGroup.cs" />
173+
<Compile Include="Utils\FireAndForgetTask.cs" />
174+
<Compile Include="Utils\RepositoryIdentifier.cs" />
175+
<Compile Include="Utils\SimpleJson.cs" />
176+
<Compile Include="Utils\StringExtensions.cs" />
177+
<Compile Include="ViewModels\App\BaseDefaultStartupViewModel.cs" />
178+
<Compile Include="ViewModels\App\BaseMenuViewModel.cs" />
179+
<Compile Include="ViewModels\BaseAccountsViewModel.cs" />
180+
<Compile Include="ViewModels\BaseStartupViewModel.cs" />
181+
<Compile Include="ViewModels\BaseViewModel.cs" />
182+
<Compile Include="ViewModels\CollectionViewModel.cs" />
183+
<Compile Include="ViewModels\FileSourceViewModel.cs" />
184+
<Compile Include="ViewModels\FilterableCollectionViewModel.cs" />
185+
<Compile Include="ViewModels\FilterGroup.cs" />
186+
<Compile Include="ViewModels\FilterModel.cs" />
187+
<Compile Include="ViewModels\IFilterableViewModel.cs" />
188+
<Compile Include="ViewModels\WebBrowserViewModel.cs" />
189+
<Compile Include="PresentationValues.cs" />
138190
</ItemGroup>
139191
<ItemGroup />
140192
<ItemGroup>
141193
<Reference Include="System" />
142194
<Reference Include="System.Windows" />
143195
<Reference Include="System.Core" />
196+
<Reference Include="System.Net.Http" />
197+
<Reference Include="Flurry.Analytics.Portable">
198+
<HintPath>..\CodeHub.iOS\packages\Flurry.Analytics.Portable.1.2.0\lib\portable-wp80+win80+wpa81+net45+sl50+MonoTouch10+MonoAndroid10+XamariniOS10\Flurry.Analytics.Portable.dll</HintPath>
199+
</Reference>
144200
<Reference Include="Cirrious.CrossCore">
145-
<HintPath>..\lib\CodeFramework\lib\iOS\Cirrious.CrossCore.dll</HintPath>
201+
<HintPath>..\CodeHub.iOS\packages\MvvmCross.HotTuna.CrossCore.3.5.1\lib\portable-win+net45+wp8+win8+wpa81\Cirrious.CrossCore.dll</HintPath>
202+
</Reference>
203+
<Reference Include="Cirrious.MvvmCross.Localization">
204+
<HintPath>..\CodeHub.iOS\packages\MvvmCross.HotTuna.CrossCore.3.5.1\lib\portable-win+net45+wp8+win8+wpa81\Cirrious.MvvmCross.Localization.dll</HintPath>
146205
</Reference>
147206
<Reference Include="Cirrious.MvvmCross">
148-
<HintPath>..\lib\CodeFramework\lib\iOS\Cirrious.MvvmCross.dll</HintPath>
207+
<HintPath>..\CodeHub.iOS\packages\MvvmCross.HotTuna.MvvmCrossLibraries.3.5.1\lib\portable-win+net45+wp8+win8+wpa81\Cirrious.MvvmCross.dll</HintPath>
208+
</Reference>
209+
<Reference Include="Newtonsoft.Json">
210+
<HintPath>..\CodeHub.iOS\packages\Newtonsoft.Json.7.0.1\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
211+
</Reference>
212+
<Reference Include="GitHubSharp">
213+
<HintPath>..\CodeHub.iOS\packages\GitHubClient.1.0.5.0\lib\portable-net45+win+wpa81\GitHubSharp.dll</HintPath>
149214
</Reference>
150215
<Reference Include="Cirrious.MvvmCross.Plugins.Messenger">
151-
<HintPath>..\lib\CodeFramework\lib\iOS\Cirrious.MvvmCross.Plugins.Messenger.dll</HintPath>
216+
<HintPath>..\CodeHub.iOS\packages\MvvmCross.HotTuna.Plugin.Messenger.3.5.1\lib\portable-win+net45+wp8+win8+wpa81\Cirrious.MvvmCross.Plugins.Messenger.dll</HintPath>
152217
</Reference>
153-
<Reference Include="System.Net.Http" />
154-
</ItemGroup>
155-
<ItemGroup>
156-
<ProjectReference Include="..\lib\GitHubSharp\GitHubSharp.MonoTouch.csproj">
157-
<Project>{89E14828-85BB-4790-9B4E-E44DD4CE000E}</Project>
158-
<Name>GitHubSharp.MonoTouch</Name>
159-
</ProjectReference>
160-
<ProjectReference Include="..\lib\CodeFramework\CodeFramework.iOS\CodeFramework.iOS.csproj">
161-
<Project>{2698B412-26A3-4269-AA01-AC3BC79A0F14}</Project>
162-
<Name>CodeFramework.iOS</Name>
163-
</ProjectReference>
164-
<ProjectReference Include="..\lib\CodeFramework\CodeFramework.Core\CodeFramework.Core.csproj">
165-
<Project>{C99FE7E3-0985-48F1-9EBB-91680A795F0F}</Project>
166-
<Name>CodeFramework.Core</Name>
167-
</ProjectReference>
218+
<Reference Include="Xamarin.iOS" />
168219
</ItemGroup>
169-
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
170220
<ItemGroup />
171221
<ItemGroup>
172222
<Content Include="Markdown\marked.js" />
@@ -177,5 +227,10 @@
177227
<Folder Include="ViewModels\Teams\" />
178228
<Folder Include="ViewModels\Changesets\" />
179229
<Folder Include="ViewModels\Notifications\" />
230+
<Folder Include="Cache\" />
231+
</ItemGroup>
232+
<ItemGroup>
233+
<None Include="packages.config" />
180234
</ItemGroup>
235+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
181236
</Project>

CodeHub.Core/Data/Account.cs

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
using System;
2+
using System.Globalization;
3+
using System.IO;
4+
using Cirrious.CrossCore;
5+
using CodeFramework.Core.Services;
6+
using SQLite;
7+
8+
namespace CodeFramework.Core.Data
9+
{
10+
public abstract class Account : IAccount, IDisposable
11+
{
12+
private SQLiteConnection _database;
13+
private AccountFilters _filters;
14+
private AccountPinnedRepositories _pinnedRepositories;
15+
private AccountCache _cache;
16+
17+
[PrimaryKey]
18+
[AutoIncrement]
19+
public int Id { get; set; }
20+
21+
/// <summary>
22+
/// Gets or sets the username.
23+
/// </summary>
24+
/// <value>The username.</value>
25+
public string Username { get; set; }
26+
27+
/// <summary>
28+
/// Gets or sets the avatar URL.
29+
/// </summary>
30+
/// <value>The avatar URL.</value>
31+
public string AvatarUrl { get; set; }
32+
33+
/// <summary>
34+
/// Gets or sets the name of the startup view when the account is loaded
35+
/// </summary>
36+
/// <value>The startup view.</value>
37+
public string DefaultStartupView { get; set; }
38+
39+
/// <summary>
40+
/// Gets or sets a value indicating whether this <see cref="Account"/> dont remember.
41+
/// THIS HAS TO BE A NEGATIVE STATEMENT SINCE IT DEFAULTS TO 'FALSE' WHEN RETRIEVING A NULL VIA SQLITE
42+
/// </summary>
43+
public bool DontRemember { get; set; }
44+
45+
[Ignore]
46+
public SQLiteConnection Database
47+
{
48+
get
49+
{
50+
if (_database == null)
51+
{
52+
if (!Directory.Exists(AccountDirectory))
53+
Directory.CreateDirectory(AccountDirectory);
54+
55+
var dbPath = Path.Combine(AccountDirectory, "settings.db");
56+
_database = new SQLiteConnection(dbPath);
57+
return _database;
58+
}
59+
60+
return _database;
61+
}
62+
}
63+
64+
[Ignore]
65+
public string AccountDirectory
66+
{
67+
get
68+
{
69+
var accountsDir = Mvx.Resolve<IAccountPreferencesService>().AccountsDir;
70+
return Path.Combine(accountsDir, Id.ToString(CultureInfo.InvariantCulture));
71+
}
72+
}
73+
74+
[Ignore]
75+
public AccountFilters Filters
76+
{
77+
get
78+
{
79+
return _filters ?? (_filters = new AccountFilters(Database));
80+
}
81+
}
82+
83+
[Ignore]
84+
public AccountPinnedRepositories PinnnedRepositories
85+
{
86+
get
87+
{
88+
return _pinnedRepositories ?? (_pinnedRepositories = new AccountPinnedRepositories(Database));
89+
}
90+
}
91+
92+
[Ignore]
93+
public AccountCache Cache
94+
{
95+
get
96+
{
97+
return _cache ?? (_cache = new AccountCache(Database, Mvx.Resolve<IAccountPreferencesService>().CacheDir));
98+
}
99+
}
100+
101+
private void CreateAccountDirectory()
102+
{
103+
if (!Directory.Exists(AccountDirectory))
104+
Directory.CreateDirectory(AccountDirectory);
105+
}
106+
107+
/// <summary>
108+
/// This creates this account's directory
109+
/// </summary>
110+
public void Initialize()
111+
{
112+
CreateAccountDirectory();
113+
}
114+
115+
/// <summary>
116+
/// This destorys this account's directory
117+
/// </summary>
118+
public void Destory()
119+
{
120+
if (!Directory.Exists(AccountDirectory))
121+
return;
122+
Cache.DeleteAll();
123+
Directory.Delete(AccountDirectory, true);
124+
}
125+
126+
127+
/// <summary>
128+
/// Returns a <see cref="System.String"/> that represents the current <see cref="Account"/>.
129+
/// </summary>
130+
/// <returns>A <see cref="System.String"/> that represents the current <see cref="Account"/>.</returns>
131+
public override string ToString()
132+
{
133+
return Username;
134+
}
135+
136+
public void Dispose()
137+
{
138+
if (_database != null) _database.Dispose();
139+
}
140+
141+
/// <summary>
142+
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="Account"/>.
143+
/// </summary>
144+
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="Account"/>.</param>
145+
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
146+
/// <see cref="Account"/>; otherwise, <c>false</c>.</returns>
147+
public override bool Equals(object obj)
148+
{
149+
if (ReferenceEquals(null, obj))
150+
return false;
151+
if (ReferenceEquals(this, obj))
152+
return true;
153+
var act = obj as Account;
154+
return act != null && this.Id.Equals(act.Id);
155+
}
156+
157+
/// <summary>
158+
/// Serves as a hash function for a particular type.
159+
/// </summary>
160+
/// <returns>
161+
/// A hash code for the current <see cref="T:System.Object"/>.
162+
/// </returns>
163+
/// <filterpriority>2</filterpriority>
164+
public override int GetHashCode()
165+
{
166+
return this.Id;
167+
}
168+
}
169+
}
170+

0 commit comments

Comments
 (0)