├── .gitignore ├── Core ├── API │ ├── Commits.cs │ ├── Gist.cs │ ├── Issues.cs │ ├── Network.cs │ ├── Object.cs │ ├── PullRequest.cs │ ├── Repository.cs │ └── User.cs ├── AssemblyInfo.cs ├── Base │ ├── BaseAPI.cs │ ├── Enums.cs │ ├── GithubApiBase.cs │ ├── IBaseApi.cs │ ├── JsonConverter.cs │ └── Url.cs ├── Core.csproj ├── Github.cs ├── GithubAuthenticationException.cs ├── GithubException.cs ├── GithubFailedResponse.cs ├── GithubRequest.cs ├── GithubRequestWithInputAndReturnType.cs ├── GithubRequestWithReturnType.cs ├── GithubResponse.cs ├── GithubURLs.cs ├── Helpers │ └── URLUtils.cs ├── Models │ ├── BasicUser.cs │ ├── ChangeStatus.cs │ ├── Comment.cs │ ├── Commit.cs │ ├── Fork.cs │ ├── Gist.cs │ ├── GithubUser.cs │ ├── History.cs │ ├── Internal │ │ ├── Commit.cs │ │ ├── Issues.cs │ │ ├── JsonSimpleDictionary.cs │ │ ├── Network.cs │ │ ├── Object.cs │ │ ├── PullRequest.cs │ │ ├── Repository.cs │ │ └── User.cs │ ├── Issue.cs │ ├── Network.cs │ ├── Object.cs │ ├── PullRequest.cs │ ├── Repository.cs │ └── User.cs └── Services │ ├── IAuthProvider.cs │ ├── ICacheProvider.cs │ └── ILogProvider.cs ├── GithubSharp.sln ├── Libs ├── munq │ ├── Munq.CommonServiceLocator.dll │ ├── Munq.IocContainer.dll │ ├── Munq.MVC2.dll │ └── Munq.MVC3.dll ├── mvc │ ├── System.Web.Abstractions.dll │ ├── System.Web.Helpers.dll │ ├── System.Web.Mvc.dll │ ├── System.Web.Razor.dll │ ├── System.Web.Routing.dll │ ├── System.Web.WebPages.Deployment.dll │ ├── System.Web.WebPages.Razor.dll │ └── System.Web.WebPages.dll ├── nunit │ ├── nunit.framework.dll │ ├── nunit.framework.xml │ └── nunit.mocks.dll └── servicestack │ ├── ServiceStack.Text.XML │ └── ServiceStack.Text.dll ├── NOTES ├── Plugins ├── AuthProviders │ ├── NullAuthProvider │ │ ├── AssemblyInfo.cs │ │ ├── NullAuthProvider.cs │ │ └── NullAuthProvider.csproj │ └── UserPasswordAuthProvider │ │ ├── AssemblyInfo.cs │ │ ├── UserPasswordAuthProvider.cs │ │ └── UserPasswordAuthProvider.csproj ├── CacheProviders │ ├── ApplicationCacher │ │ ├── ApplicationCacher.cs │ │ ├── ApplicationCacher.csproj │ │ └── AssemblyInfo.cs │ ├── BasicCacher │ │ ├── BasicCacher.cs │ │ ├── BasicCacher.csproj │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── NullCacher │ │ ├── AssemblyInfo.cs │ │ ├── NullCacher.cs │ │ └── NullCacher.csproj │ └── WebCache │ │ ├── AssemblyInfo.cs │ │ ├── WebCache.csproj │ │ └── WebCacher.cs └── LogProviders │ ├── NullLogger │ ├── AssemblyInfo.cs │ ├── NullLogger.cs │ └── NullLogger.csproj │ └── SimpleLogProvider │ ├── Properties │ └── AssemblyInfo.cs │ ├── SimpleLogProvider.cs │ └── SimpleLogProvider.csproj ├── README ├── Samples ├── ConsoleSample │ ├── ConsoleSample.csproj │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── app.config └── MvcSample │ ├── MvcApplication │ ├── Controllers │ │ ├── BaseAPIController.cs │ │ ├── BaseController.cs │ │ ├── CommitController.cs │ │ ├── HomeController.cs │ │ ├── IssuesController.cs │ │ ├── NetworkController.cs │ │ ├── ObjectController.cs │ │ ├── RepositoryController.cs │ │ └── UserController.cs │ ├── Default.cs │ ├── Models │ │ ├── HtmlHelpers │ │ │ └── AdditionalHtmlAndUrlHelpers.cs │ │ └── ViewModels │ │ │ ├── BaseViewModel.cs │ │ │ ├── ErrorViewModel.cs │ │ │ └── LoginViewModel.cs │ ├── MvcApplication.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ └── ServerApp.cs │ └── MvcUI │ ├── Default.aspx │ ├── Global.asax │ ├── MvcUI.csproj │ ├── Properties │ └── AssemblyInfo.cs │ ├── Views │ ├── Commit │ │ ├── Commit.aspx │ │ ├── CommitRenderer.ascx │ │ ├── Commits.aspx │ │ ├── Index.aspx │ │ └── SingleFileCommitRenderer.ascx │ ├── Gists │ │ └── Index.aspx │ ├── Home │ │ └── Index.aspx │ ├── Issues │ │ ├── Comments.aspx │ │ ├── Index.aspx │ │ ├── Issue.ascx │ │ ├── Labels.aspx │ │ ├── List.aspx │ │ └── View.aspx │ ├── Network │ │ └── Index.aspx │ ├── Object │ │ └── Index.aspx │ ├── Repository │ │ ├── Branches.aspx │ │ ├── Create.aspx │ │ ├── Delete.aspx │ │ ├── Get.aspx │ │ ├── Languages.aspx │ │ ├── List.aspx │ │ ├── Network.aspx │ │ ├── PublicKeys.aspx │ │ ├── Search.aspx │ │ └── Tags.aspx │ ├── Shared │ │ ├── Error.cshtml │ │ ├── Footer.cshtml │ │ ├── Login.cshtml │ │ ├── LoginControl.cshtml │ │ ├── LoginDisplay.cshtml │ │ ├── Menu.cshtml │ │ └── _Layout.cshtml │ ├── User │ │ └── Index.aspx │ ├── Web.config │ └── _ViewStart.cshtml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── css │ ├── blueprint.min.css │ ├── grid.png │ ├── ie.min.css │ ├── main.css │ └── main.min.css │ ├── images │ ├── favicon.ico │ └── githubsharp.png │ └── js │ ├── jquery-1.4.1.min-vsdoc.js │ ├── jquery-1.4.1.min.js │ ├── main.js │ └── main.min.js ├── Tests └── CoreTests │ ├── CoreTests.csproj │ ├── GistModelTest.cs │ ├── GithubRequestTest.cs │ └── TestSettings.cs ├── build ├── nuget ├── GithubSharp.Core.nuspec ├── GithubSharp.Plugins.All.nuspec └── GithubSharp.nuspec ├── runtests └── runtests.bat /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | #ignore thumbnails created by windows 3 | Thumbs.db 4 | #Ignore files build by Visual Studio 5 | *.obj 6 | *.exe 7 | *.pdb 8 | *.user 9 | *.aps 10 | *.pch 11 | *.vspscc 12 | *_i.c 13 | *_p.c 14 | *.ncb 15 | *.suo 16 | *.tlb 17 | *.tlh 18 | *.bak 19 | *.cache 20 | *.ilk 21 | *.log 22 | [Bb]in 23 | [Dd]ebug*/ 24 | *.lib 25 | *.sbr 26 | obj/ 27 | [Rr]elease*/ 28 | _ReSharper*/ 29 | [Tt]est[Rr]esult* 30 | [Pp]ublished/* 31 | [Mm]aterials/* 32 | *.pidb 33 | *.userprefs 34 | *~ 35 | *.nupkg 36 | test[\-]results 37 | TestResult.xml 38 | -------------------------------------------------------------------------------- /Core/API/Commits.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using GithubSharp.Core.Services; 3 | using GithubSharp.Core.Models; 4 | 5 | namespace GithubSharp.Core.API 6 | { 7 | public class Commits : Base.BaseApi 8 | { 9 | public Commits(ICacheProvider CacheProvider, ILogProvider LogProvider) : base(CacheProvider, LogProvider) { } 10 | 11 | public IEnumerable CommitsForBranch( 12 | string Username, 13 | string RepositoryName, 14 | string BranchName) 15 | { 16 | LogProvider.LogMessage(string.Format("Commits.CommitsForBranch - Username : '{0}', RepositoryName : '{1}', Branch : '{2}'", 17 | Username, 18 | RepositoryName, 19 | BranchName)); 20 | 21 | var url = string.Format("commits/list/{0}/{1}/{2}", 22 | Username, 23 | RepositoryName, 24 | BranchName); 25 | 26 | var result = ConsumeJsonUrl(url); 27 | 28 | return result != null ? result.Commits : null; 29 | } 30 | 31 | 32 | public IEnumerable CommitsForFile( 33 | string Username, 34 | string RepositoryName, 35 | string BranchName, 36 | string FilePath) 37 | { 38 | LogProvider.LogMessage(string.Format("Commits.CommitsForFile - Username : '{0}', RepositoryName : '{1}', Branch : '{2}', Path : '{3}'", 39 | Username, 40 | RepositoryName, 41 | BranchName, 42 | FilePath)); 43 | 44 | var url = string.Format("commits/list/{0}/{1}/{2}/{3}", 45 | Username, 46 | RepositoryName, 47 | BranchName, 48 | FilePath); 49 | 50 | var result = ConsumeJsonUrl(url); 51 | 52 | return result != null ? result.Commits : null; 53 | } 54 | 55 | 56 | public SingleFileCommit CommitForSingleFile( 57 | string Username, 58 | string RepositoryName, 59 | string CommitShaId) 60 | { 61 | LogProvider.LogMessage(string.Format("Commits.CommitForSingleFile - Username : '{0}', RepositoryName : '{1}', CommitShaId : '{2}'", 62 | Username, 63 | RepositoryName, 64 | CommitShaId)); 65 | 66 | var url = string.Format("commits/show/{0}/{1}/{2}", 67 | Username, 68 | RepositoryName, 69 | CommitShaId); 70 | 71 | var result = ConsumeJsonUrl(url); 72 | 73 | return result != null ? result.Commit : null; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Core/API/Network.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using GithubSharp.Core.Services; 3 | using GithubSharp.Core.Models; 4 | 5 | namespace GithubSharp.Core.API 6 | { 7 | public class Network : Base.BaseApi 8 | { 9 | public Network(ICacheProvider CacheProvider, ILogProvider LogProvider) : base(CacheProvider, LogProvider) { } 10 | 11 | public NetworkMeta Meta(string Username, string RepositoryName) 12 | { 13 | LogProvider.LogMessage(string.Format("Network.Meta - Username : '{0}', RepositoryName : '{1}'", Username, RepositoryName)); 14 | 15 | var url = string.Format("http://github.com/{0}/{1}/network_meta", Username, RepositoryName); 16 | 17 | return ConsumeJsonUrl(url); 18 | } 19 | 20 | public IEnumerable MetaChunks(string Username, string RepositoryName, string NetworkHash) 21 | { 22 | return MetaChunks(Username, RepositoryName, NetworkHash, -1, -1); 23 | } 24 | 25 | public IEnumerable MetaChunks(string Username, string RepositoryName, string NetworkHash, int Start, int End) 26 | { 27 | LogProvider.LogMessage(string.Format("Network.MetaChunks - Username : '{0}', RepositoryName : '{1}', NetworkHash : '{2}', Start : '{3}', End : '{4}'", 28 | Username, 29 | RepositoryName, 30 | NetworkHash, 31 | Start, 32 | End)); 33 | 34 | var url = string.Format("http://github.com/{0}/{1}/network_data_chunk?nethash={2}{3}", 35 | Username, 36 | RepositoryName, 37 | NetworkHash, 38 | End > 0 && Start > -1 ? 39 | string.Format("?start={0}&end={1}", Start, End) : string.Empty); 40 | 41 | var result = ConsumeJsonUrl(url); 42 | 43 | return result != null ? result.Commits : null; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Core/API/Object.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using GithubSharp.Core.Services; 3 | using GithubSharp.Core.Models; 4 | 5 | namespace GithubSharp.Core.API 6 | { 7 | public class Object : Base.BaseApi 8 | { 9 | public Object(ICacheProvider CacheProvider, ILogProvider LogProvider) : base(CacheProvider, LogProvider) { } 10 | 11 | public IEnumerable Trees( 12 | string Username, 13 | string RepositoryName, 14 | string TreeSha) 15 | { 16 | LogProvider.LogMessage(string.Format("Object.Trees - TreeSha : '{0}' , Username : '{1}', RepositoryName : '{2}'", TreeSha, Username, RepositoryName)); 17 | 18 | var url = string.Format("tree/show/{0}/{1}/{2}", 19 | Username, 20 | RepositoryName, 21 | TreeSha); 22 | 23 | var result = ConsumeJsonUrl(url); 24 | 25 | return result == null ? null : result.Tree; 26 | } 27 | 28 | public Blob Blob( 29 | string Username, 30 | string RepositoryName, 31 | string TreeSha, 32 | string Path) 33 | { 34 | LogProvider.LogMessage(string.Format("Object.Blob - TreeSha : '{0}' , Username : '{1}', RepositoryName : '{2}', Path : '{3}'", 35 | TreeSha, 36 | Username, 37 | RepositoryName, 38 | Path)); 39 | 40 | var url = string.Format("blob/show/{0}/{1}/{2}/{3}", 41 | Username, 42 | RepositoryName, 43 | TreeSha, 44 | Path); 45 | 46 | var result = ConsumeJsonUrl(url); 47 | 48 | return result == null ? null : result.Blob; 49 | } 50 | 51 | public Dictionary BlobList( 52 | string Username, 53 | string RepositoryName, 54 | string TreeSha) 55 | { 56 | LogProvider.LogMessage(string.Format("Object.BlobList - TreeSha : '{0}' , Username : '{1}', RepositoryName : '{2}'", 57 | TreeSha, 58 | Username, 59 | RepositoryName)); 60 | 61 | var url = string.Format("blob/all/{0}/{1}/{2}", 62 | Username, 63 | RepositoryName, 64 | TreeSha); 65 | 66 | var result = ConsumeJsonUrl(url); 67 | 68 | return result == null ? null : result.Blobs; 69 | } 70 | 71 | public byte[] RawBinary( 72 | string Username, 73 | string RepositoryName, 74 | string BlobSha) 75 | { 76 | LogProvider.LogMessage(string.Format("Object.RawBinary - BlobSha : '{0}' , Username : '{1}', RepositoryName : '{2}'", 77 | BlobSha, 78 | Username, 79 | RepositoryName)); 80 | 81 | var url = string.Format("blob/show/{0}/{1}/{2}", 82 | Username, 83 | RepositoryName, 84 | BlobSha); 85 | 86 | return ConsumeUrlToBinary(url); 87 | } 88 | 89 | public string RawString( 90 | string Username, 91 | string RepositoryName, 92 | string BlobSha) 93 | { 94 | LogProvider.LogMessage(string.Format("Object.RawString - BlobSha : '{0}' , Username : '{1}', RepositoryName : '{2}'", 95 | BlobSha, 96 | Username, 97 | RepositoryName)); 98 | 99 | var url = string.Format("blob/show/{0}/{1}/{2}", 100 | Username, 101 | RepositoryName, 102 | BlobSha); 103 | 104 | return ConsumeUrlToString(url); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Core/API/PullRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using GithubSharp.Core.Services; 6 | using System.Collections.Specialized; 7 | 8 | namespace GithubSharp.Core.API 9 | { 10 | public class PullRequest : Base.BaseApi 11 | { 12 | public PullRequest(ICacheProvider CacheProvider, ILogProvider LogProvider) : base(CacheProvider, LogProvider) { } 13 | 14 | public IEnumerable List(string Username, string RepositoryName) 15 | { 16 | return List(Username, RepositoryName, null); 17 | } 18 | 19 | public IEnumerable List(string Username, string RepositoryName, string State) 20 | { 21 | LogProvider.LogMessage(string.Format("PullRequest.List - {0} - {1} - {2}", Username, RepositoryName, State)); 22 | var url = string.Format("pulls/{0}/{1}{2}", Username, RepositoryName, string.IsNullOrEmpty(State) ? "" : "/" + State); 23 | var result = ConsumeJsonUrl(url); 24 | return result == null ? null : result.PullRequests; 25 | } 26 | 27 | public Models.PullRequest GetById(string Username, string RepositoryName, string Id) 28 | { 29 | LogProvider.LogMessage(string.Format("PullRequest.GetById - {0} - {1} - {2}", Username, RepositoryName, Id)); 30 | var url = string.Format("pulls/{0}/{1}/{2}", Username, RepositoryName, Id); 31 | var result = ConsumeJsonUrl(url); 32 | return result == null ? null : result.PullRequest; 33 | } 34 | 35 | public Models.PullRequest Create(string Username, string RepositoryName, string BaseRef, string HeadRef, string Title, string Body) 36 | { 37 | LogProvider.LogMessage(string.Format("PullRequest.Create - {0} - {1} - {2} - {3} - {4}", Username, RepositoryName, BaseRef, HeadRef, Title)); 38 | if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(RepositoryName) || string.IsNullOrEmpty(BaseRef) || string.IsNullOrEmpty(HeadRef) || string.IsNullOrEmpty(Title) || string.IsNullOrEmpty(Body)) 39 | return null; 40 | 41 | var url = string.Format("pulls/{0}/{1}", Username, RepositoryName); 42 | 43 | var formValues = new NameValueCollection(); 44 | formValues.Add("pull[base]", BaseRef); 45 | formValues.Add("pull[head]", HeadRef); 46 | formValues.Add("pull[title]", Title); 47 | formValues.Add("pull[body]", Body); 48 | 49 | var result = ConsumeJsonUrlAndPostData(url, formValues); 50 | 51 | return result != null ? result.PullRequest : null; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Core/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("Core")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | -------------------------------------------------------------------------------- /Core/Base/Enums.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core.Base 4 | { 5 | public enum GithubSharpHttpVerbs 6 | { 7 | Get, 8 | Post, 9 | Patch, 10 | Delete, 11 | Put, 12 | Head, 13 | Options 14 | } 15 | 16 | public enum GithubSharpMimeTypes 17 | { 18 | Raw, 19 | Text, 20 | Html, 21 | Full, 22 | Json 23 | } 24 | 25 | public static class EnumHelper 26 | { 27 | public static string ToString(this GithubSharpHttpVerbs verb) 28 | { 29 | switch (verb) 30 | { 31 | case GithubSharpHttpVerbs.Get: return "GET"; 32 | case GithubSharpHttpVerbs.Post: return "POST"; 33 | case GithubSharpHttpVerbs.Patch: return "PATCH"; 34 | case GithubSharpHttpVerbs.Delete: return "DELETE"; 35 | case GithubSharpHttpVerbs.Put: return "PUT"; 36 | case GithubSharpHttpVerbs.Head: return "HEAD"; 37 | default: return "OPTIONS"; 38 | } 39 | } 40 | 41 | public static string ToString(this GithubSharpMimeTypes mime) 42 | { 43 | const string mimeBase = "application/vnd.github.{0}+json"; 44 | switch (mime) 45 | { 46 | case GithubSharpMimeTypes.Raw: return string.Format(mimeBase, "raw"); 47 | case GithubSharpMimeTypes.Text: return string.Format(mimeBase, "text"); 48 | case GithubSharpMimeTypes.Html: return string.Format(mimeBase, "html"); 49 | case GithubSharpMimeTypes.Full: return string.Format(mimeBase, "full"); 50 | default: return "application/vnd.github.json"; 51 | } 52 | } 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /Core/Base/GithubApiBase.cs: -------------------------------------------------------------------------------- 1 | namespace GithubSharp.Core.Base 2 | { 3 | public class GithubApiBase 4 | { 5 | public GithubApiBase( 6 | Services.ILogProvider logProvider, 7 | Services.ICacheProvider cacheProvider, 8 | Services.IAuthProvider authProvider) 9 | { 10 | LogProvider = logProvider; 11 | CacheProvider = cacheProvider; 12 | AuthProvider = authProvider; 13 | } 14 | 15 | public Services.ILogProvider LogProvider { get; set; } 16 | public Services.ICacheProvider CacheProvider { get; set; } 17 | public Services.IAuthProvider AuthProvider { get; set; } 18 | 19 | protected IGithubResponse Get( 20 | string path, 21 | GithubSharpHttpVerbs method) 22 | { 23 | return new GithubRequest( 24 | LogProvider, 25 | CacheProvider, 26 | AuthProvider, 27 | path, 28 | method).GetResponse(); 29 | } 30 | 31 | protected IGithubResponseWithReturnType Get( 32 | string path, 33 | GithubSharpHttpVerbs method) 34 | where TReturnType : class 35 | { 36 | return new GithubRequestWithReturnType( 37 | LogProvider, 38 | CacheProvider, 39 | AuthProvider, 40 | path, 41 | method) 42 | .GetResponseWithReturnType(); 43 | } 44 | 45 | protected IGithubResponseWithReturnType Get( 46 | string path, 47 | GithubSharpHttpVerbs method, 48 | TInputType toSend) 49 | where TReturnType : class 50 | { 51 | return new GithubRequestWithInputAndReturnType( 52 | LogProvider, 53 | CacheProvider, 54 | AuthProvider, 55 | path, 56 | method, 57 | toSend) 58 | .GetResponseWithReturnType(); 59 | } 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Core/Base/IBaseApi.cs: -------------------------------------------------------------------------------- 1 | using GithubSharp.Core.Services; 2 | 3 | namespace GithubSharp.Core.Base 4 | { 5 | public interface IBaseApi 6 | { 7 | void Authenticate(); 8 | void Authenticate(Models.GithubUser user); 9 | ILogProvider LogProvider { get; set; } 10 | ICacheProvider CacheProvider { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Core/Base/JsonConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core.Base 4 | { 5 | internal static class JsonConverter 6 | { 7 | /// 8 | /// Serializes the object to a Json string 9 | /// 10 | internal static string ToJson(this T Obj) 11 | { 12 | return ServiceStack.Text.JsonSerializer.SerializeToString(Obj); 13 | } 14 | 15 | internal static byte[] ToJsonBytes(this T TObj) 16 | { 17 | var jsonString = ToJson(TObj); 18 | return System.Text.Encoding.UTF8.GetBytes(jsonString); 19 | } 20 | 21 | /// 22 | /// Deserializes 23 | /// 24 | /// 25 | internal static T FromJson(string Json) 26 | { 27 | if (string.IsNullOrEmpty(Json)) 28 | throw new ArgumentNullException("Json"); 29 | return ServiceStack.Text.JsonSerializer.DeserializeFromString(Json); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Core/GithubAuthenticationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core 4 | { 5 | public class GithubAuthenticationException : Exception 6 | { 7 | public GithubAuthenticationException(string uri) 8 | : base(string.Format("Failed to authenticate for {0}", uri)) 9 | { 10 | } 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Core/GithubException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace GithubSharp.Core 5 | { 6 | public class GithubException : Exception 7 | { 8 | public GithubException(System.Net.HttpWebResponse response, string uri) 9 | : base(string.Format("Github error when retrieving {0}", uri)) 10 | { 11 | var responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); 12 | GithubErrorResult = Base.JsonConverter.FromJson(responseString); 13 | StatusCode = (int)response.StatusCode; 14 | StatusText = response.StatusDescription; 15 | } 16 | 17 | public GithubErrorModel GithubErrorResult { get; set; } 18 | public int StatusCode { get; set; } 19 | public string StatusText { get; set; } 20 | } 21 | 22 | 23 | public class GithubErrorResponse : GithubResponseWithReturnType 24 | { 25 | 26 | } 27 | 28 | 29 | public class GithubErrorModel 30 | { 31 | public string message 32 | { 33 | get; 34 | set; 35 | } 36 | public IEnumerable errors 37 | { 38 | get; 39 | set; 40 | } 41 | } 42 | 43 | public class GithubErrorDetails 44 | { 45 | public string Resource 46 | { 47 | get; 48 | set; 49 | } 50 | 51 | public string Field 52 | { 53 | get; 54 | set; 55 | } 56 | 57 | public string Code 58 | { 59 | get; 60 | set; 61 | } 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Core/GithubFailedResponse.cs: -------------------------------------------------------------------------------- 1 | namespace GithubSharp.Core 2 | { 3 | public class GithubFailedResponse : GithubResponse 4 | { 5 | public GithubFailedResponse(string uri) 6 | { 7 | FailedUri = uri; 8 | } 9 | 10 | public string FailedUri 11 | { 12 | get; 13 | set; 14 | } 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Core/GithubRequestWithInputAndReturnType.cs: -------------------------------------------------------------------------------- 1 | using GithubSharp.Core.Services; 2 | using GithubSharp.Core.Base; 3 | 4 | namespace GithubSharp.Core 5 | { 6 | public class GithubRequestWithInputAndReturnType : GithubRequestWithReturnType 7 | where TReturnType : class 8 | { 9 | public GithubRequestWithInputAndReturnType( 10 | ILogProvider logProvider, 11 | ICacheProvider cacheProvider, 12 | IAuthProvider authProvider, 13 | string path, 14 | TInputType input) 15 | : base(logProvider, 16 | cacheProvider, 17 | authProvider, 18 | path) 19 | { 20 | ModelToSend = input; 21 | } 22 | public GithubRequestWithInputAndReturnType( 23 | ILogProvider logProvider, 24 | ICacheProvider cacheProvider, 25 | IAuthProvider authProvider, 26 | string path, 27 | GithubSharpHttpVerbs method, 28 | TInputType input) 29 | : base(logProvider, 30 | cacheProvider, 31 | authProvider, 32 | path, 33 | method) 34 | { 35 | ModelToSend = input; 36 | } 37 | 38 | public TInputType ModelToSend { get; set; } 39 | 40 | 41 | public override System.Net.HttpWebRequest PrepareWebRequest(System.Net.HttpWebRequest webRequest) 42 | { 43 | webRequest = base.PrepareWebRequest(webRequest); 44 | webRequest.ContentType = "application/json"; //Get from MimeType? 45 | webRequest.MediaType = "UTF-8"; 46 | var bytes = ModelToSend.ToJsonBytes(); 47 | 48 | webRequest.ContentLength = bytes.Length; 49 | var stream = webRequest.GetRequestStream(); 50 | stream.Write(bytes, 0, bytes.Length); 51 | stream.Close(); 52 | 53 | return webRequest; 54 | } 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /Core/GithubRequestWithReturnType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using GithubSharp.Core.Base; 3 | 4 | namespace GithubSharp.Core 5 | { 6 | public class GithubRequestWithReturnType : GithubRequest 7 | where TReturnType : class 8 | { 9 | public GithubRequestWithReturnType(Services.ILogProvider logProvider, 10 | Services.ICacheProvider cacheProvider, 11 | Services.IAuthProvider authProvider, 12 | string path) 13 | : base( 14 | logProvider, 15 | cacheProvider, 16 | authProvider, 17 | path) 18 | { 19 | } 20 | 21 | public GithubRequestWithReturnType(Services.ILogProvider logProvider, 22 | Services.ICacheProvider cacheProvider, 23 | Services.IAuthProvider authProvider, 24 | string path, 25 | GithubSharpHttpVerbs method) 26 | : base(logProvider, cacheProvider, authProvider, path, method) 27 | { 28 | } 29 | 30 | public override bool IsCached(string uri) 31 | { 32 | return CacheProvider.IsCached(uri); 33 | } 34 | 35 | public IGithubResponseWithReturnType GetResponseWithReturnType() 36 | { 37 | var baseResult = base.GetResponse(); 38 | var baseWithReturnType = new GithubResponseWithReturnType 39 | { 40 | LinkNext = baseResult.LinkNext, 41 | LinkFirst = baseResult.LinkFirst, 42 | LinkLast = baseResult.LinkLast, 43 | LinkPrevious = baseResult.LinkPrevious, 44 | RateLimitLimit = baseResult.RateLimitLimit, 45 | RateLimitRemaining = baseResult.RateLimitRemaining, 46 | Response = baseResult.Response 47 | }; 48 | 49 | try 50 | { 51 | baseWithReturnType.Result = JsonConverter 52 | .FromJson(baseWithReturnType.Response); 53 | } 54 | catch (Exception error) 55 | { 56 | if (LogProvider.HandleAndReturnIfToThrowError(error)) 57 | throw; 58 | } 59 | 60 | return baseWithReturnType; 61 | } 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Core/GithubResponse.cs: -------------------------------------------------------------------------------- 1 | namespace GithubSharp.Core 2 | { 3 | public interface IGithubResponse 4 | { 5 | int RateLimitLimit { get; set; } 6 | int RateLimitRemaining { get; set; } 7 | string Response { get; set; } 8 | string LinkNext { get; set; } 9 | string LinkPrevious { get; set; } 10 | string LinkFirst { get; set; } 11 | string LinkLast { get; set; } 12 | int? StatusCode { get; set; } 13 | string StatusText { get; set; } 14 | } 15 | 16 | public interface IGithubResponseWithReturnType : IGithubResponse 17 | where TResultType : class 18 | { 19 | TResultType Result { get; set; } 20 | } 21 | 22 | public class GithubResponse : IGithubResponse 23 | { 24 | public int RateLimitLimit { get; set; } 25 | public int RateLimitRemaining { get; set; } 26 | public string Response { get; set; } 27 | public string LinkNext { get; set; } 28 | public string LinkPrevious { get; set; } 29 | public string LinkFirst { get; set; } 30 | public string LinkLast { get; set; } 31 | public int? StatusCode { get; set; } 32 | public string StatusText { get; set; } 33 | } 34 | 35 | public class GithubResponseWithReturnType : GithubResponse, IGithubResponseWithReturnType 36 | where TResultType : class 37 | { 38 | public TResultType Result 39 | { 40 | get; 41 | set; 42 | } 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Core/GithubURLs.cs: -------------------------------------------------------------------------------- 1 | namespace GithubSharp.Core 2 | { 3 | public class GithubURLs 4 | { 5 | public static string GithubApiBaseUrl 6 | { 7 | get { return "https://api.github.com"; } 8 | } 9 | 10 | 11 | public Models.GithubUser User { get; set; } 12 | private string _LoginString 13 | { 14 | get 15 | { 16 | return User != null && !string.IsNullOrEmpty(User.Name) && !string.IsNullOrEmpty(User.APIToken) ? 17 | string.Format("?login={0}&token={1}", User.Name, User.APIToken) 18 | : string.Empty; 19 | } 20 | } 21 | 22 | public string Repositories(string User) 23 | { 24 | return string.Format("http://github.com/api/v2/xml/repos/show/{0}{1}", User, _LoginString); 25 | } 26 | public string Repository(string User, string Repository) 27 | { 28 | return string.Format("http://github.com/api/v2/xml/repos/show/{0}/{1}{2}", User, Repository, _LoginString); 29 | } 30 | 31 | public string RawFile(string User, string Repository, string File) 32 | { 33 | return RawFile(User, Repository, File, "master"); 34 | } 35 | 36 | public string RawFile(string User, string Repository, string File, string TreeShaOrBranchName) 37 | { 38 | return string.Format("http://github.com/{0}/{1}/raw/{2}/{3}{4}", User, Repository, File, TreeShaOrBranchName, _LoginString); 39 | } 40 | 41 | public string Commits(string User, string Repository) 42 | { 43 | return Commits(User, Repository, "master"); 44 | } 45 | 46 | public string Commits(string User, string Repository, string BranchName) 47 | { 48 | return string.Format("http://github.com/api/v2/xml/commits/list/{0}/{1}/{2}{3}", User, Repository, BranchName, _LoginString); 49 | } 50 | 51 | public string BlobOrTree(string User, string Repository, string BlobOrThreeSha) 52 | { 53 | return string.Format("http://github.com/api/v2/xml/blob/show/{0}/{1}/{2}{3}", User, Repository, BlobOrThreeSha, _LoginString); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Core/Helpers/URLUtils.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | 4 | namespace GithubSharp.Core.Helpers 5 | { 6 | public class URLUtils 7 | { 8 | prot XDocument _GetXMLFromURL(string URL) 9 | { 10 | string cacheKey = string.Format("GetXMLFromURL_{0}", URL); 11 | var cached = _CacheProvider.Get( 12 | cacheKey); 13 | if (cached != null) 14 | return cached; 15 | string resultXML = _GetStringFromURL(URL); 16 | if (string.IsNullOrEmpty(resultXML)) 17 | return null; 18 | 19 | XDocument result = null; 20 | try 21 | { 22 | result = XDocument.Parse(resultXML); 23 | } 24 | catch 25 | { 26 | return null; 27 | } 28 | _CacheProvider.Set(result, cacheKey); 29 | return result; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/Models/BasicUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core.Models 4 | { 5 | [Serializable] 6 | public class BasicUser 7 | { 8 | public string login { get; set; } 9 | public int id { get; set; } 10 | public string avatar_url { get; set; } 11 | public string gravatar_id { get; set; } 12 | public string url { get; set; } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Core/Models/ChangeStatus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core.Models 4 | { 5 | [Serializable] 6 | public class ChangeStatus 7 | { 8 | public ChangeStatus () 9 | { 10 | } 11 | public int deletions { get; set; } 12 | public int additions { get; set; } 13 | public int total { get; set; } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Core/Models/Comment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core.Models 4 | { 5 | [Serializable] 6 | public class Comment 7 | { 8 | public string id { get; set; } 9 | public string url { get; set; } 10 | public string body { get; set; } 11 | public string body_text { get; set; } 12 | public string body_html { get; set; } 13 | public BasicUser user { get; set; } 14 | public DateTime created_at { get; set; } 15 | } 16 | 17 | [Serializable] 18 | public class CommentForCreationOrEdit 19 | { 20 | public string body { get; set; } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Core/Models/Commit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.Serialization; 4 | 5 | namespace GithubSharp.Core.Models 6 | { 7 | public class Commit 8 | { 9 | public List parents { get; set; } 10 | 11 | public Person author { get; set; } 12 | 13 | public string url { get; set; } 14 | 15 | public string sha { get; set; } 16 | 17 | public string message { get; set; } 18 | 19 | public CommmitParent tree { get; set; } 20 | 21 | public Person committer { get; set; } 22 | } 23 | 24 | public class CommmitParent 25 | { 26 | public string sha { get; set; } 27 | 28 | public string url { get; set; } 29 | } 30 | 31 | public class Person 32 | { 33 | public string name { get; set; } 34 | 35 | public DateTime date { get; set; } 36 | 37 | public string email { get; set; } 38 | } 39 | 40 | [DataContract] 41 | public class SingleFileCommit : Commit 42 | { 43 | [DataMember(Name = "added")] 44 | public IEnumerable Added { get; set; } 45 | 46 | [DataMember(Name = "removed")] 47 | public IEnumerable Removed { get; set; } 48 | 49 | [DataMember(Name = "modified")] 50 | public IEnumerable Modified { get; set; } 51 | } 52 | 53 | [DataContract] 54 | public class SingleFileCommitFileReference 55 | { 56 | [DataMember(Name = "filename")] 57 | public string Filename { get; set; } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Core/Models/Fork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core.Models 4 | { 5 | [Serializable] 6 | public class Fork 7 | { 8 | public Fork () 9 | { 10 | } 11 | 12 | public BasicUser user {get;set;} 13 | public string url { get; set; } 14 | public DateTime created_at { get; set; } 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Core/Models/Gist.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace GithubSharp.Core.Models 5 | { 6 | [Serializable] 7 | public class Gist 8 | { 9 | public string url { get; set; } 10 | public string id { get; set; } 11 | public string description { get; set; } 12 | public bool @public { get; set; } 13 | public BasicUser user { get; set; } 14 | public Dictionary files { get; set; } 15 | public int comments { get; set; } 16 | public string html_url { get; set; } 17 | public string git_pull_url { get; set; } 18 | public string git_push_url { get; set; } 19 | public DateTime created_at { get; set; } 20 | public List forks { get; set; } 21 | public List history { get; set; } 22 | } 23 | 24 | [Serializable] 25 | public class GistFile 26 | { 27 | public int size { get; set; } 28 | public string filename { get; set; } 29 | public string raw_url { get; set; } 30 | public string content { get; set; } 31 | } 32 | 33 | [Serializable] 34 | public class GistToCreateOrEdit 35 | { 36 | public string description { get; set; } 37 | public bool @public { get; set; } 38 | public Dictionary files { get; set; } 39 | } 40 | 41 | [Serializable] 42 | public class GistFileForCreation 43 | { 44 | public string content { get; set; } 45 | } 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /Core/Models/GithubUser.cs: -------------------------------------------------------------------------------- 1 | namespace GithubSharp.Core.Models 2 | { 3 | public class GithubUser 4 | { 5 | public string Name { get; set; } 6 | public string APIToken { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Core/Models/History.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core.Models 4 | { 5 | [Serializable] 6 | public class History 7 | { 8 | public History () 9 | { 10 | } 11 | public string url { get; set; } 12 | public string version { get; set; } 13 | public BasicUser user { get; set; } 14 | public ChangeStatus change_status { get; set; } 15 | public DateTime committed_at { get; set; } 16 | 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Core/Models/Internal/Commit.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | 4 | namespace GithubSharp.Core.Models.Internal 5 | { 6 | [DataContract] 7 | internal class CommitListContainer 8 | { 9 | [DataMember(Name = "commits")] 10 | public IEnumerable Commits { get; set; } 11 | } 12 | 13 | [DataContract] 14 | internal class SingleFileCommitContainer 15 | { 16 | [DataMember(Name = "commit")] 17 | public SingleFileCommit Commit { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Models/Internal/Issues.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | 4 | namespace GithubSharp.Core.Models.Internal 5 | { 6 | [DataContract] 7 | public class IssuesCollection 8 | { 9 | [DataMember(Name = "issues")] 10 | public IEnumerable Issues { get; set; } 11 | } 12 | 13 | [DataContract] 14 | public class IssueContainer 15 | { 16 | [DataMember(Name = "issue")] 17 | public Issue Issue { get; set; } 18 | } 19 | 20 | [DataContract] 21 | public class LabelsCollection 22 | { 23 | [DataMember(Name = "labels")] 24 | public string[] Labels { get; set; } 25 | } 26 | 27 | [DataContract] 28 | public class CommentsCollection 29 | { 30 | [DataMember(Name = "comments")] 31 | public IEnumerable Comments { get; set; } 32 | } 33 | 34 | [DataContract] 35 | public class CommentSavedContainer 36 | { 37 | [DataMember(Name = "comment")] 38 | public CommentSaved Comment { get; set; } 39 | } 40 | 41 | [DataContract] 42 | public class CommentSaved 43 | { 44 | [DataMember(Name = "id")] 45 | public string Id { get; set; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/Models/Internal/JsonSimpleDictionary.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Runtime.Serialization; 6 | 7 | namespace GithubSharp.Core.Models.Internal 8 | { 9 | [Serializable] 10 | internal class JsonSimpleDictionary : ISerializable 11 | { 12 | public Dictionary Dict = new Dictionary(); 13 | 14 | public JsonSimpleDictionary(SerializationInfo info, StreamingContext context) 15 | { 16 | foreach (var entry in info) 17 | { 18 | Dict.Add(entry.Name, (string)entry.Value); 19 | } 20 | } 21 | 22 | public void GetObjectData(SerializationInfo info, StreamingContext context) 23 | { 24 | throw new NotImplementedException("JsonSimpleDict.GetObjectData: Called. Should never happpen."); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Core/Models/Internal/Network.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | 4 | namespace GithubSharp.Core.Models.Internal 5 | { 6 | [DataContract] 7 | internal class NetworkChunkContainer 8 | { 9 | [DataMember(Name = "commits")] 10 | public IEnumerable Commits { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Models/Internal/Object.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | 4 | namespace GithubSharp.Core.Models.Internal 5 | { 6 | [DataContract] 7 | internal class ObjectContainer 8 | { 9 | [DataMember(Name = "tree")] 10 | public IEnumerable Tree { get; set; } 11 | } 12 | 13 | [DataContract] 14 | internal class BlobContainer 15 | { 16 | [DataMember(Name = "blob")] 17 | public Blob Blob { get; set; } 18 | } 19 | 20 | [DataContract] 21 | internal class BlobListContainer 22 | { 23 | [DataMember(Name = "blobs")] 24 | public Dictionary Blobs { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Models/Internal/PullRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Runtime.Serialization; 6 | 7 | namespace GithubSharp.Core.Models.Internal 8 | { 9 | [DataContract] 10 | internal class PullRequestCollection 11 | { 12 | [DataMember(Name = "pulls")] 13 | public IEnumerable PullRequests { get; set; } 14 | } 15 | 16 | [DataContract] 17 | internal class PullRequestContainer 18 | { 19 | [DataMember(Name = "pull")] 20 | public Models.PullRequest PullRequest { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Core/Models/Internal/Repository.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | using System; 4 | 5 | namespace GithubSharp.Core.Models.Internal 6 | { 7 | [DataContract] 8 | internal class RepositoryCollection 9 | { 10 | [DataMember(Name = "repositories")] 11 | public IEnumerable Repositories { get; set; } 12 | } 13 | 14 | [DataContract] 15 | internal class RepositoryContainer 16 | { 17 | [DataMember(Name = "repository")] 18 | public TRepoType Repository { get; set; } 19 | } 20 | 21 | [DataContract] 22 | internal class RepositoryFromNetworkContainer 23 | { 24 | [DataMember(Name = "network")] 25 | public IEnumerable Network { get; set; } 26 | } 27 | 28 | [DataContract] 29 | internal class RepositoryDelete 30 | { 31 | [DataMember(Name = "delete_token")] 32 | public string DeleteToken { get; set; } 33 | } 34 | 35 | [DataContract] 36 | internal class RepositoryDeleted 37 | { 38 | [DataMember(Name = "status")] 39 | public string Status { get; set; } 40 | } 41 | 42 | [DataContract] 43 | internal class LanguagesCollection 44 | { 45 | [DataMember(Name = "languages")] 46 | public Dictionary Languages { get; set; } 47 | } 48 | 49 | [DataContract] 50 | internal class TagCollection 51 | { 52 | [DataMember(Name = "tags")] 53 | public JsonSimpleDictionary Tags { get; set; } 54 | } 55 | 56 | [DataContract] 57 | internal class BranchesCollection 58 | { 59 | [DataMember(Name = "branches")] 60 | public JsonSimpleDictionary Branches { get; set; } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Core/Models/Internal/User.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | 4 | namespace GithubSharp.Core.Models.Internal 5 | { 6 | [DataContract] 7 | internal class PublicKeyCollection 8 | { 9 | [DataMember(Name = "public_keys")] 10 | public IEnumerable PublicKeys { get; set; } 11 | } 12 | 13 | [DataContract] 14 | internal class UsersCollection 15 | { 16 | [DataMember(Name = "users")] 17 | public IEnumerable Users { get; set; } 18 | } 19 | 20 | [DataContract] 21 | internal class EmailCollection 22 | { 23 | [DataMember(Name = "emails")] 24 | public IEnumerable Emails { get; set; } 25 | } 26 | 27 | [DataContract] 28 | internal class UserContainer 29 | { 30 | [DataMember(Name = "user")] 31 | public TUserType User { get; set; } 32 | } 33 | 34 | [DataContract] 35 | internal class CollaboratorsCollection 36 | { 37 | [DataMember(Name = "collaborators")] 38 | public IEnumerable Collaborators { get; set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Core/Models/Issue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace GithubSharp.Core.Models 5 | { 6 | [DataContract] 7 | public class Issue 8 | { 9 | [DataMember(Name = "number")] 10 | public int Number { get; set; } 11 | 12 | [DataMember(Name = "votes")] 13 | public int Votes { get; set; } 14 | 15 | [DataMember(Name = "created_at")] 16 | private string PrivateCreatedAt 17 | { 18 | get { return CreatedAt.ToString(); } 19 | set { CreatedAt = DateTime.Parse(value); } 20 | } 21 | public DateTime CreatedAt { get; set; } 22 | 23 | [DataMember(Name = "body")] 24 | public string Body { get; set; } 25 | 26 | [DataMember(Name = "title")] 27 | public string Title { get; set; } 28 | 29 | [DataMember(Name = "closed_at")] 30 | private string PrivateClosedAt 31 | { 32 | get { return ClosedAt.ToString(); } 33 | set 34 | { 35 | if (!string.IsNullOrEmpty(value)) 36 | ClosedAt = DateTime.Parse(value); 37 | } 38 | } 39 | public DateTime? ClosedAt { get; set; } 40 | 41 | [DataMember(Name = "user")] 42 | public string User { get; set; } 43 | 44 | [DataMember(Name = "labels")] 45 | public string[] Labels { get; set; } 46 | 47 | [DataMember(Name = "state")] //EnumMember does not work? 48 | public string State { get; set; } 49 | 50 | [DataMember(Name = "comments")] 51 | public int Comments { get; set; } 52 | 53 | [DataMember(Name = "position")] 54 | public double Position { get; set; } 55 | 56 | [DataMember(Name = "html_url")] 57 | public string HtmlUrl { get; set; } 58 | 59 | } 60 | 61 | [DataContract] 62 | public enum IssueState 63 | { 64 | [EnumMember(Value = "open")] 65 | Open, 66 | [EnumMember(Value= "closed")] 67 | Closed 68 | } 69 | 70 | [DataContract] 71 | public class CommentForIssue 72 | { 73 | [DataMember(Name = "created_at")] 74 | private string PrivateCreatedAt 75 | { 76 | get { return CreatedAt.ToString(); } 77 | set { CreatedAt = DateTime.Parse(value); } 78 | } 79 | public DateTime CreatedAt { get; set; } 80 | 81 | [DataMember(Name = "updated_at")] 82 | private string PrivateUpdatedAt 83 | { 84 | get { return UpdatedAt.ToString(); } 85 | set { UpdatedAt = DateTime.Parse(value); } 86 | } 87 | public DateTime UpdatedAt { get; set; } 88 | 89 | [DataMember(Name = "body")] 90 | public string Body { get; set; } 91 | 92 | [DataMember(Name = "id")] 93 | public int Id { get; set; } 94 | 95 | [DataMember(Name = "user")] 96 | public string User { get; set; } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Core/Models/Network.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | 6 | namespace GithubSharp.Core.Models 7 | { 8 | [DataContract] 9 | public class NetworkMeta 10 | { 11 | [DataMember(Name = "spacemap")] 12 | public IEnumerable>> Spacemap { get; set; } 13 | 14 | [DataMember(Name = "focus")] 15 | public int Focus { get; set; } 16 | 17 | [DataMember(Name = "nethash")] 18 | public string Nethash { get; set; } 19 | 20 | [DataMember(Name = "dates")] 21 | private List PrivateCreated 22 | { 23 | get 24 | { 25 | return Dates.Select(DateTime => DateTime.ToString()).ToList(); 26 | } 27 | set 28 | { 29 | if(Dates == null) Dates = new List(); 30 | foreach (var val in value) 31 | Dates.Add(DateTime.Parse(val)); 32 | } 33 | } 34 | public List Dates { get; set; } 35 | 36 | [DataMember(Name = "users")] 37 | public IEnumerable Users { get; set; } 38 | } 39 | 40 | [DataContract] 41 | public class NetworkUser 42 | { 43 | [DataMember(Name = "name")] 44 | public string Name { get; set; } 45 | 46 | [DataMember(Name = "repo")] 47 | public string Repo { get; set; } 48 | 49 | [DataMember(Name = "heads")] 50 | public IEnumerable Heads { get; set; } 51 | } 52 | 53 | [DataContract] 54 | public class NetworkUserHeadInfo 55 | { 56 | [DataMember(Name = "name")] 57 | public string Name { get; set; } 58 | 59 | [DataMember(Name = "id")] 60 | public string Id { get; set; } 61 | } 62 | 63 | [DataContract] 64 | public class NetworkBlock 65 | { 66 | [DataMember(Name = "name")] 67 | public string Name { get; set; } 68 | 69 | [DataMember(Name = "start")] 70 | public int Start { get; set; } 71 | 72 | [DataMember(Name = "count")] 73 | public int Count { get; set; } 74 | } 75 | 76 | [DataContract] 77 | public class NetworkChunk 78 | { 79 | [DataMember(Name = "author")] 80 | public string Author { get; set; } 81 | 82 | [DataMember(Name = "time")] 83 | public int Time { get; set; } 84 | 85 | [DataMember(Name = "id")] 86 | public string Id { get; set; } 87 | 88 | [DataMember(Name = "date")] 89 | private string PrivateDate 90 | { 91 | get { return Date.ToString(); } 92 | set { Date = DateTime.Parse(value); } 93 | } 94 | public DateTime Date{ get; set; } 95 | 96 | [DataMember(Name = "gravatar")] 97 | public string Gravatar { get; set; } 98 | 99 | [DataMember(Name = "space")] 100 | public int Space { get; set; } 101 | 102 | [DataMember(Name = "message")] 103 | public string Message { get; set; } 104 | 105 | [DataMember(Name = "login")] 106 | public string Login { get; set; } 107 | 108 | //TODO: Need to parse this more accurate, it's string (sha id),int (commit id/nr),int(branch?) 109 | [DataMember(Name = "parents")] 110 | public IEnumerable> Parents { get; set; } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Core/Models/Object.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace GithubSharp.Core.Models 4 | { 5 | [DataContract] 6 | public class Object 7 | { 8 | [DataMember(Name = "name")] 9 | public string Name { get; set; } 10 | 11 | [DataMember(Name = "sha")] 12 | public string Sha { get; set; } 13 | 14 | [DataMember(Name = "mode")] 15 | public string Mode { get; set; } 16 | 17 | [DataMember(Name = "type")] 18 | public string Type { get; set; } 19 | 20 | public ObjectItemType ObjectItemType 21 | { 22 | get { return Type == "blob" ? ObjectItemType.Blob : ObjectItemType.Tree; } 23 | } 24 | } 25 | 26 | [DataContract] 27 | public class Blob 28 | { 29 | [DataMember(Name = "name")] 30 | public string Name { get; set; } 31 | 32 | [DataMember(Name = "sha")] 33 | public string Sha { get; set; } 34 | 35 | [DataMember(Name = "mode")] 36 | public string Mode { get; set; } 37 | 38 | [DataMember(Name = "size")] 39 | public int Size { get; set; } 40 | 41 | [DataMember(Name = "mime_type")] 42 | public string MimeType { get; set; } 43 | 44 | [DataMember(Name = "data")] 45 | public string Data { get; set; } 46 | } 47 | 48 | public enum ObjectItemType 49 | { 50 | Blob, 51 | Tree 52 | } 53 | } -------------------------------------------------------------------------------- /Core/Models/Repository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace GithubSharp.Core.Models 5 | { 6 | [DataContract] 7 | public class Repository 8 | { 9 | [DataMember(Name = "url")] 10 | public string URL { get; set; } 11 | 12 | [DataMember(Name = "description")] 13 | public string Description { get; set; } 14 | 15 | [DataMember(Name = "homepage")] 16 | public string Homepage { get; set; } 17 | 18 | [DataMember(Name = "name")] 19 | public string Name { get; set; } 20 | 21 | [DataMember(Name = "owner")] 22 | public string Owner { get; set; } 23 | 24 | [DataMember(Name = "fork")] 25 | public bool Fork { get; set; } 26 | 27 | [DataMember(Name = "private")] 28 | public bool Private { get; set; } 29 | 30 | [DataMember(Name = "open_issues")] 31 | public int OpenIssues { get; set; } 32 | 33 | [DataMember(Name = "watchers")] 34 | public int Watchers { get; set; } 35 | 36 | [DataMember(Name = "forks")] 37 | public int Forks { get; set; } 38 | 39 | [DataMember(Name = "source")] 40 | public string Source { get; set; } 41 | 42 | [DataMember(Name = "parent")] 43 | public string Parent { get; set; } 44 | 45 | public string WatchersURL { get { return string.Format("http://github.com/{0}/{1}/watchers", Owner, Name); } } 46 | public string DownloadURL { get { return string.Format("http://github.com/{0}/{1}/zipball/master", Owner, Name); } } 47 | public string ForksURL { get { return string.Format("http://github.com/{0}/{1}/network/members", Owner, Name); } } 48 | public string IssuesURL { get { return string.Format("http://github.com/{0}/{1}/issues", Owner, Name); } } 49 | public string WikiURL { get { return string.Format("http://wiki.github.com/{0}/{1}", Owner, Name); } } 50 | public string GraphsURL { get { return string.Format("http://github.com/{0}/{1}/graphs", Owner, Name); } } 51 | public string ForkQuoueURL { get { return string.Format("http://github.com/{0}/{1}/forkqueue", Owner, Name); } } 52 | public string GitCloneURL { get { return string.Format("git://github.com/{0}/{1}.git", Owner, Name); } } 53 | public string HttpCloneURL { get { return string.Format("http://github.com/{0}/{1}.git", Owner, Name); } } 54 | public string ForkURL { get { return string.Format("http://github.com/{0}/{1}/fork", Owner, Name); } } 55 | public string WatchURL { get { return string.Format("http://github.com/{0}/{1}/toggle_watch", Owner, Name); } } 56 | } 57 | 58 | [DataContract] 59 | public class RepositoryFromSearch 60 | { 61 | [DataMember(Name = "name")] 62 | public string Name { get; set; } 63 | 64 | [DataMember(Name = "size")] 65 | public int Size { get; set; } 66 | 67 | [DataMember(Name = "followers")] 68 | public int Followers { get; set; } 69 | 70 | [DataMember(Name = "username")] 71 | public string Username { get; set; } 72 | 73 | [DataMember(Name = "language")] 74 | public string Language { get; set; } 75 | 76 | [DataMember(Name = "fork")] 77 | public bool Fork { get; set; } 78 | 79 | [DataMember(Name = "id")] 80 | public string Id { get; set; } 81 | 82 | [DataMember(Name = "type")] 83 | public string Type { get; set; } 84 | 85 | [DataMember(Name = "pushed")] 86 | private string PrivatePushed 87 | { 88 | get { return Pushed.ToString(); } 89 | set 90 | { 91 | Pushed = value != null ? DateTime.Parse(value) : default(DateTime); 92 | } 93 | } 94 | public DateTime Pushed { get; set; } 95 | 96 | [DataMember(Name = "forks")] 97 | public int Forks { get; set; } 98 | 99 | [DataMember(Name = "description")] 100 | public string Description { get; set; } 101 | 102 | [DataMember(Name = "score")] 103 | public float Score { get; set; } 104 | 105 | [DataMember(Name = "created")] 106 | private string PrivateCreated 107 | { 108 | get { return Created.ToString(); } 109 | set { Created = value != null ? DateTime.Parse(value) : default(DateTime); } 110 | } 111 | public DateTime Created { get; set; } 112 | } 113 | 114 | [DataContract] 115 | public class Language 116 | { 117 | public string Name { get; set; } 118 | public int CalculatedBytes { get; set; } 119 | } 120 | 121 | [DataContract] 122 | public class TagOrBranch 123 | { 124 | public string Name { get; set; } 125 | public string Sha { get; set; } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Core/Models/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace GithubSharp.Core.Models 5 | { 6 | [DataContract] 7 | public class UserInCollection 8 | { 9 | [DataMember(Name = "name")] 10 | public string Name { get; set; } 11 | 12 | [DataMember(Name = "location")] 13 | public string Location { get; set; } 14 | 15 | [DataMember(Name = "followers")] 16 | public int Followers { get; set; } 17 | 18 | [DataMember(Name = "username")] 19 | public string Username { get; set; } 20 | 21 | [DataMember(Name = "language")] 22 | public string Language { get; set; } 23 | 24 | [DataMember(Name = "fullname")] 25 | public string Fullname { get; set; } 26 | 27 | [DataMember(Name = "repos")] 28 | public int Repos { get; set; } 29 | 30 | [DataMember(Name = "id")] 31 | public string Id { get; set; } 32 | 33 | [DataMember(Name = "type")] 34 | public string Type { get; set; } 35 | 36 | [DataMember(Name = "pushed")] 37 | private string PrivatePushed 38 | { 39 | get { return Pushed.ToString(); } 40 | set { Pushed = DateTime.Parse(value); } 41 | } 42 | public DateTime Pushed { get; set; } 43 | 44 | [DataMember(Name = "score")] 45 | public float Score { get; set; } 46 | 47 | [DataMember(Name = "created")] 48 | private string PrivateCreated 49 | { 50 | get { return Created.ToString(); } 51 | set { Created = DateTime.Parse(value); } 52 | } 53 | public DateTime Created { get; set; } 54 | } 55 | 56 | [DataContract] 57 | public class User 58 | { 59 | [DataMember(Name = "gravatar_id")] 60 | public string GravatarId { get; set; } 61 | 62 | [DataMember(Name = "name")] 63 | public string Name { get; set; } 64 | 65 | [DataMember(Name = "company")] 66 | public string Company { get; set; } 67 | 68 | [DataMember(Name = "location")] 69 | public string Location { get; set; } 70 | 71 | [DataMember(Name = "created_at")] 72 | private string PrivateCreatedAt 73 | { 74 | get { return CreatedAt.ToString(); } 75 | set { CreatedAt = DateTime.Parse(value); } 76 | } 77 | public DateTime CreatedAt { get; set; } 78 | 79 | [DataMember(Name = "public_gist_count")] 80 | public int PublicGistCount { get; set; } 81 | 82 | [DataMember(Name = "public_repo_count")] 83 | public int PublicRepoCount { get; set; } 84 | 85 | [DataMember(Name = "blog")] 86 | public string Blog { get; set; } 87 | 88 | [DataMember(Name = "following")] 89 | public int Following { get; set; } 90 | 91 | [DataMember(Name = "id")] 92 | public int Id { get; set; } 93 | 94 | [DataMember(Name = "login")] 95 | public string Login { get; set; } 96 | 97 | [DataMember(Name = "email")] 98 | public string Email { get; set; } 99 | } 100 | 101 | [DataContract] 102 | public class UserAuthenticated : User 103 | { 104 | [DataMember(Name = "total_private_repo_count")] 105 | public int TotalPrivateRepoCount { get; set; } 106 | 107 | [DataMember(Name = "collaborators")] 108 | public int Collaborators { get; set; } 109 | 110 | [DataMember(Name = "disk_usage")] 111 | public int DiskUsage { get; set; } 112 | 113 | [DataMember(Name = "owned_private_repo_count")] 114 | public int OwnedPrivateRepoCount { get; set; } 115 | 116 | [DataMember(Name = "private_gist_count")] 117 | public int PrivateGistCount { get; set; } 118 | 119 | [DataMember(Name = "plan")] 120 | public UserAuthenticatedPlan Plan { get; set; } 121 | } 122 | 123 | [DataContract] 124 | public class UserAuthenticatedPlan 125 | { 126 | [DataMember(Name = "name")] 127 | public string Name { get; set; } 128 | 129 | [DataMember(Name = "collaborators")] 130 | public int Collaborators { get; set; } 131 | 132 | [DataMember(Name = "space")] 133 | public int Space { get; set; } 134 | 135 | [DataMember(Name = "private_repos")] 136 | public int PrivateRepos { get; set; } 137 | } 138 | 139 | [DataContract] 140 | public class PublicKey 141 | { 142 | [DataMember(Name = "title")] 143 | public string Title { get; set; } 144 | 145 | [DataMember(Name = "id")] 146 | public int Id { get; set; } 147 | 148 | [DataMember(Name = "key")] 149 | public string Key { get; set; } 150 | } 151 | 152 | 153 | } 154 | -------------------------------------------------------------------------------- /Core/Services/IAuthProvider.cs: -------------------------------------------------------------------------------- 1 | namespace GithubSharp.Core.Services 2 | { 3 | public interface IAuthProvider 4 | { 5 | IAuthResponse Login(); 6 | IAuthResponse Logout(); 7 | IAuthPreRequestResponse PreRequestAuth( 8 | IGithubRequest githubRequest, 9 | System.Net.HttpWebRequest webRequest); 10 | string PrepareUri(string uri); 11 | string GetToken(); 12 | void RestoreFromToken(string token); 13 | bool IsAuthenticated { get; set; } 14 | string Username { get; set; } 15 | } 16 | 17 | public interface IAuthResponse 18 | { 19 | bool Success { get; set; } 20 | string Message { get; set; } 21 | } 22 | 23 | public class AuthResponse : IAuthResponse 24 | { 25 | public bool Success { get; set; } 26 | public string Message { get; set; } 27 | } 28 | 29 | public interface IAuthPreRequestResponse : IAuthResponse 30 | { 31 | System.Net.HttpWebRequest WebRequest 32 | { 33 | get; 34 | set; 35 | } 36 | } 37 | 38 | public class AuthPreRequestResponse : AuthResponse, IAuthPreRequestResponse 39 | { 40 | public System.Net.HttpWebRequest WebRequest 41 | { 42 | get; 43 | set; 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Core/Services/ICacheProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core.Services 4 | { 5 | 6 | public interface ICacheProvider 7 | { 8 | T Get(string name) where T : class; 9 | T Get(string name, int cacheDurationInMinutes) where T : class; 10 | bool IsCached(string name) where T : class; 11 | void Set(T objectToCache, string name) where T : class; 12 | void Delete(string name); 13 | void DeleteWhereStartingWith(string name); 14 | void DeleteAll() where T : class; 15 | int DefaultDuractionInMinutes { get; } 16 | } 17 | 18 | public class CachedObject where T : class 19 | { 20 | public T Cached { get; set; } 21 | public DateTime When { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/Services/ILogProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Core.Services 4 | { 5 | public interface ILogProvider 6 | { 7 | bool DebugMode { get; set; } 8 | void LogMessage(string Message, params object[] Arguments); 9 | void LogWarning(string Message, params object[] Arguments); 10 | bool HandleAndReturnIfToThrowError(Exception error); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Libs/munq/Munq.CommonServiceLocator.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/munq/Munq.CommonServiceLocator.dll -------------------------------------------------------------------------------- /Libs/munq/Munq.IocContainer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/munq/Munq.IocContainer.dll -------------------------------------------------------------------------------- /Libs/munq/Munq.MVC2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/munq/Munq.MVC2.dll -------------------------------------------------------------------------------- /Libs/munq/Munq.MVC3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/munq/Munq.MVC3.dll -------------------------------------------------------------------------------- /Libs/mvc/System.Web.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/mvc/System.Web.Abstractions.dll -------------------------------------------------------------------------------- /Libs/mvc/System.Web.Helpers.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/mvc/System.Web.Helpers.dll -------------------------------------------------------------------------------- /Libs/mvc/System.Web.Mvc.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/mvc/System.Web.Mvc.dll -------------------------------------------------------------------------------- /Libs/mvc/System.Web.Razor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/mvc/System.Web.Razor.dll -------------------------------------------------------------------------------- /Libs/mvc/System.Web.Routing.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/mvc/System.Web.Routing.dll -------------------------------------------------------------------------------- /Libs/mvc/System.Web.WebPages.Deployment.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/mvc/System.Web.WebPages.Deployment.dll -------------------------------------------------------------------------------- /Libs/mvc/System.Web.WebPages.Razor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/mvc/System.Web.WebPages.Razor.dll -------------------------------------------------------------------------------- /Libs/mvc/System.Web.WebPages.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/mvc/System.Web.WebPages.dll -------------------------------------------------------------------------------- /Libs/nunit/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/nunit/nunit.framework.dll -------------------------------------------------------------------------------- /Libs/nunit/nunit.mocks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/nunit/nunit.mocks.dll -------------------------------------------------------------------------------- /Libs/servicestack/ServiceStack.Text.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Libs/servicestack/ServiceStack.Text.dll -------------------------------------------------------------------------------- /NOTES: -------------------------------------------------------------------------------- 1 | Continue to implement models to understand the needs of the base api class 2 | Add attribute for an api method that needs authentication? 3 | Add a simple parameterized string format for methods? 4 | Add raw url helper methods - with content types? 5 | 6 | Test date parsing.. 7 | 8 | Refactor GithubRe[quest|sponse] To base? -------------------------------------------------------------------------------- /Plugins/AuthProviders/NullAuthProvider/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("NullAuthProvider")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("erikz")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /Plugins/AuthProviders/NullAuthProvider/NullAuthProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Plugins.AuthProviders.NullAuthProvider 4 | { 5 | public class NullAuthProvider : GithubSharp.Core.Services.IAuthProvider 6 | { 7 | public NullAuthProvider () 8 | { 9 | } 10 | 11 | public GithubSharp.Core.Services.IAuthResponse Login () 12 | { 13 | return new GithubSharp.Core.Services.AuthResponse 14 | { 15 | Success = true 16 | }; 17 | } 18 | 19 | public GithubSharp.Core.Services.IAuthResponse Logout () 20 | { 21 | return new GithubSharp.Core.Services.AuthResponse 22 | { 23 | Success = true 24 | }; 25 | } 26 | 27 | public GithubSharp.Core.Services.IAuthPreRequestResponse PreRequestAuth ( 28 | GithubSharp.Core.IGithubRequest githubRequest, 29 | System.Net.HttpWebRequest webRequest) 30 | { 31 | return new GithubSharp.Core.Services.AuthPreRequestResponse 32 | { 33 | Success = true, 34 | WebRequest = webRequest 35 | }; 36 | } 37 | 38 | public bool IsAuthenticated 39 | { 40 | get { return true;} 41 | set{ return;} 42 | } 43 | 44 | 45 | public string PrepareUri(string uri) 46 | { 47 | return uri; 48 | } 49 | 50 | public string GetToken () 51 | { 52 | return string.Empty; 53 | } 54 | 55 | public void RestoreFromToken (string token) 56 | { 57 | 58 | } 59 | 60 | public string Username {get;set;} 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Plugins/AuthProviders/NullAuthProvider/NullAuthProvider.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.0 7 | 2.0 8 | {3C916941-003B-480E-9981-2B9FEFFBF447} 9 | Library 10 | GithubSharp.Plugins.AuthProviders.NullAuthProvider 11 | GithubSharp.Plugins.AuthProviders.NullAuthProvider 12 | v3.5 13 | 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug 20 | DEBUG 21 | prompt 22 | 4 23 | false 24 | 25 | 26 | none 27 | false 28 | bin\Release 29 | prompt 30 | 4 31 | false 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 43 | Core %28Core\Core%29 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Plugins/AuthProviders/UserPasswordAuthProvider/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("UserPasswordAuthProvider")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("erikz")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /Plugins/AuthProviders/UserPasswordAuthProvider/UserPasswordAuthProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Plugins.AuthProviders.UserPasswordAuthProvider 4 | { 5 | public class UserPasswordAuthProvider : GithubSharp.Core.Services.IAuthProvider 6 | { 7 | public string Password { 8 | get; 9 | set; 10 | } 11 | 12 | public UserPasswordAuthProvider (string Token) 13 | { 14 | this.RestoreFromToken(Token); 15 | } 16 | 17 | public UserPasswordAuthProvider (string user, string password) 18 | { 19 | Username = user; 20 | Password = password; 21 | IsAuthenticated = true; 22 | } 23 | 24 | public GithubSharp.Core.Services.IAuthResponse Login () 25 | { 26 | //Make a request to test the login? 27 | return new GithubSharp.Core.Services.AuthResponse 28 | { 29 | Success = true 30 | }; 31 | } 32 | 33 | public GithubSharp.Core.Services.IAuthResponse Logout () 34 | { 35 | return new GithubSharp.Core.Services.AuthResponse 36 | { 37 | Success = true 38 | }; 39 | } 40 | 41 | public GithubSharp.Core.Services.IAuthPreRequestResponse PreRequestAuth ( 42 | GithubSharp.Core.IGithubRequest githubRequest, 43 | System.Net.HttpWebRequest webRequest) 44 | { 45 | var authInfo = string.Format("{0}:{1}",Username, Password); 46 | authInfo = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(authInfo)); 47 | webRequest.Headers["Authorization"] = "Basic " + authInfo; 48 | return new GithubSharp.Core.Services.AuthPreRequestResponse 49 | { 50 | Success = true, 51 | WebRequest = webRequest 52 | }; 53 | } 54 | 55 | public string PrepareUri(string uri) 56 | { 57 | return uri; 58 | } 59 | 60 | public string GetToken () 61 | { 62 | //TODO : Hash details here? 63 | return string.Empty; 64 | } 65 | 66 | public void RestoreFromToken (string token) 67 | { 68 | //TODO : Unhash details here? 69 | } 70 | 71 | public bool IsAuthenticated {get;set;} 72 | public string Username {get;set;} 73 | 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Plugins/AuthProviders/UserPasswordAuthProvider/UserPasswordAuthProvider.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.0 7 | 2.0 8 | {61EFFFA9-0713-47CA-95D9-193E16BBA3B9} 9 | Library 10 | GithubSharp.Plugins.AuthProviders.UserPasswordAuthProvider 11 | GithubSharp.Plugins.AuthProviders.UserPasswordAuthProvider 12 | v3.5 13 | 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug 20 | DEBUG; 21 | prompt 22 | 4 23 | false 24 | 25 | 26 | none 27 | false 28 | bin\Release 29 | prompt 30 | 4 31 | false 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 43 | Core %28Core\Core%29 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/ApplicationCacher/ApplicationCacher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using GithubSharp.Core.Services; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace GithubSharp.Plugins.CacheProviders.ApplicationCacher 7 | { 8 | public class ApplicationCacher : ICacheProvider 9 | { 10 | public ApplicationCacher() 11 | { 12 | if (HttpContext.Current == null) 13 | throw new NullReferenceException("System.Web.HttpContext.Current is null"); 14 | if (HttpContext.Current.Application == null) 15 | throw new NullReferenceException("System.Web.HttpContext.Current.Application is null"); 16 | _application = HttpContext.Current.Application; 17 | } 18 | 19 | private readonly HttpApplicationState _application; 20 | private const string CachePrefix = "GithubSharp.Plugins.CacheProviders.ApplicationCacher"; 21 | 22 | #region ICacheProvider implementation 23 | public T Get (string Name) 24 | where T : class 25 | { 26 | return Get(Name, DefaultDuractionInMinutes); 27 | } 28 | 29 | 30 | public T Get (string Name, int CacheDurationInMinutes) 31 | where T : class 32 | { 33 | var cached = _application[CachePrefix + Name] as CachedObject; 34 | if (cached == null) 35 | return null; 36 | 37 | if (cached.When.AddMinutes(CacheDurationInMinutes) < DateTime.Now) 38 | return null; 39 | 40 | return cached.Cached; 41 | } 42 | 43 | 44 | public bool IsCached (string Name) 45 | where T : class 46 | { 47 | return Get(Name) != null; 48 | } 49 | 50 | 51 | public void Set (T ObjectToCache, string Name) 52 | where T : class 53 | { 54 | var cacheObj = new CachedObject(); 55 | cacheObj.Cached = ObjectToCache; 56 | cacheObj.When = DateTime.Now; 57 | 58 | _application[CachePrefix + Name] = cacheObj; 59 | } 60 | 61 | 62 | public void Delete (string Name) 63 | { 64 | _application.Remove(CachePrefix + Name); 65 | } 66 | 67 | 68 | public void DeleteWhereStartingWith (string Name) 69 | { 70 | _application.AllKeys.Where(P => P.StartsWith(CachePrefix + Name)).ToList().ForEach(Key => _application.Remove(Key)); 71 | } 72 | 73 | 74 | public void DeleteAll () 75 | where T : class 76 | { 77 | _application.AllKeys.Where(P => P.StartsWith(CachePrefix)).ToList().ForEach(Key => 78 | { 79 | var obj = _application[Key] as CachedObject; 80 | if (obj != null) 81 | { 82 | _application.Remove(Key); 83 | } 84 | }); 85 | } 86 | 87 | 88 | public int DefaultDuractionInMinutes { 89 | get { return 20;} 90 | } 91 | 92 | #endregion 93 | 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/ApplicationCacher/ApplicationCacher.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {44196ED8-BD8F-4D50-A906-A3B038F00570} 9 | Library 10 | GithubSharp.Plugins.CacheProviders.ApplicationCacher 11 | GithubSharp.Plugins.CacheProviders.ApplicationCacher 12 | v3.5 13 | 14 | 15 | 3.5 16 | 17 | false 18 | publish\ 19 | true 20 | Disk 21 | false 22 | Foreground 23 | 7 24 | Days 25 | false 26 | false 27 | true 28 | 0 29 | 1.0.0.%2a 30 | false 31 | true 32 | 33 | 34 | true 35 | full 36 | false 37 | ..\..\..\bin\ 38 | DEBUG 39 | prompt 40 | 4 41 | false 42 | AllRules.ruleset 43 | 44 | 45 | none 46 | false 47 | ..\..\..\bin\ 48 | prompt 49 | 4 50 | false 51 | AllRules.ruleset 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | False 67 | .NET Framework 3.5 SP1 Client Profile 68 | false 69 | 70 | 71 | False 72 | .NET Framework 3.5 SP1 73 | true 74 | 75 | 76 | False 77 | Windows Installer 3.1 78 | true 79 | 80 | 81 | 82 | 83 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 84 | Core %28Core\Core%29 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/ApplicationCacher/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("ApplicationCacher")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/BasicCacher/BasicCacher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using GithubSharp.Core.Services; 4 | 5 | namespace BasicCacher 6 | { 7 | public class BasicCacher : ICacheProvider 8 | { 9 | [ThreadStatic] 10 | private static Dictionary _cache; 11 | 12 | private const string CachePrefix = "GithubSharp.Plugins.CacheProviders.BasicCacher"; 13 | 14 | public BasicCacher() 15 | { 16 | _cache = new Dictionary(); 17 | } 18 | 19 | public T Get(string Name) where T : class 20 | { 21 | return Get(Name, DefaultDuractionInMinutes); 22 | } 23 | 24 | public T Get(string Name, int CacheDurationInMinutes) where T : class 25 | { 26 | if (!_cache.ContainsKey(CachePrefix + Name)) return null; 27 | var cached = _cache[CachePrefix + Name] as CachedObject; 28 | if (cached == null) return null; 29 | 30 | if (cached.When.AddMinutes(CacheDurationInMinutes) < DateTime.Now) 31 | return null; 32 | 33 | return cached.Cached; 34 | } 35 | 36 | public bool IsCached(string Name) where T : class 37 | { 38 | return _cache.ContainsKey(CachePrefix + Name); 39 | } 40 | 41 | public void Set(T ObjectToCache, string Name) where T : class 42 | { 43 | var cacheObj = new CachedObject(); 44 | cacheObj.Cached = ObjectToCache; 45 | cacheObj.When = DateTime.Now; 46 | 47 | _cache[CachePrefix + Name] = cacheObj; 48 | } 49 | 50 | public void Delete(string Name) 51 | { 52 | _cache.Remove(CachePrefix + Name); 53 | } 54 | 55 | public void DeleteWhereStartingWith(string Name) 56 | { 57 | var enumerator = _cache.GetEnumerator(); 58 | 59 | while (enumerator.MoveNext()) 60 | { 61 | if (enumerator.Current.Key.StartsWith(CachePrefix + Name)) 62 | _cache.Remove(enumerator.Current.Key); 63 | } 64 | } 65 | 66 | public void DeleteAll() where T : class 67 | { 68 | _cache.Clear(); 69 | } 70 | 71 | public int DefaultDuractionInMinutes 72 | { 73 | get { return 20; } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/BasicCacher/BasicCacher.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {5EB1DF0E-EDBD-44EB-8A63-070F13A5D0EE} 9 | Library 10 | Properties 11 | BasicCacher 12 | BasicCacher 13 | v3.5 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | ..\..\..\bin\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | ..\..\..\bin\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 48 | Core %28Core\Core%29 49 | 50 | 51 | 52 | 59 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/BasicCacher/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BasicCacher")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("BasicCacher")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("73f1e091-0f32-4b2c-b628-026586650dcd")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/NullCacher/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("NullCacher")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("erikz")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/NullCacher/NullCacher.cs: -------------------------------------------------------------------------------- 1 | namespace GithubSharp.Plugins.CacheProviders.NullCacher 2 | { 3 | public class NullCacher : Core.Services.ICacheProvider 4 | { 5 | public T Get (string name) where T : class 6 | { 7 | return null; 8 | } 9 | 10 | public T Get (string name, int cacheDurationInMinutes) where T : class 11 | { 12 | return null; 13 | } 14 | 15 | public bool IsCached (string name) where T : class 16 | { 17 | return false; 18 | } 19 | 20 | public void Set (T objectToCache, string name) where T : class 21 | { 22 | } 23 | 24 | public void Delete (string name) 25 | { 26 | } 27 | 28 | public void DeleteWhereStartingWith (string name) 29 | { 30 | } 31 | 32 | public void DeleteAll () where T : class 33 | { 34 | } 35 | 36 | public int DefaultDuractionInMinutes { 37 | get { 38 | return 1; 39 | } 40 | } 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/NullCacher/NullCacher.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.0 7 | 2.0 8 | {D2AA69DA-E0F8-4583-B161-48E763DB8D23} 9 | Library 10 | GithubSharp.Plugins.CacheProviders.NullCacher 11 | GithubSharp.Plugins.CacheProviders.NullCacher 12 | v3.5 13 | 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug 20 | DEBUG 21 | prompt 22 | 4 23 | false 24 | 25 | 26 | none 27 | false 28 | bin\Release 29 | prompt 30 | 4 31 | false 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 43 | Core %28Core\Core%29 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/WebCache/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("WebCache")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/WebCache/WebCache.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {4CF09821-4DF8-4DFE-B22E-3EBAE4A01C33} 9 | Library 10 | GithubSharp.Plugins.CacheProviders.WebCache 11 | GithubSharp.Plugins.CacheProviders.WebCache 12 | v3.5 13 | 14 | 15 | 3.5 16 | 17 | false 18 | publish\ 19 | true 20 | Disk 21 | false 22 | Foreground 23 | 7 24 | Days 25 | false 26 | false 27 | true 28 | 0 29 | 1.0.0.%2a 30 | false 31 | true 32 | 33 | 34 | true 35 | full 36 | false 37 | ..\..\..\bin\ 38 | DEBUG 39 | prompt 40 | 4 41 | false 42 | AllRules.ruleset 43 | 44 | 45 | none 46 | false 47 | ..\..\..\bin\ 48 | prompt 49 | 4 50 | false 51 | AllRules.ruleset 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | False 67 | .NET Framework 3.5 SP1 Client Profile 68 | false 69 | 70 | 71 | False 72 | .NET Framework 3.5 SP1 73 | true 74 | 75 | 76 | False 77 | Windows Installer 3.1 78 | true 79 | 80 | 81 | 82 | 83 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 84 | Core %28Core\Core%29 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Plugins/CacheProviders/WebCache/WebCacher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | using GithubSharp.Core.Services; 4 | 5 | namespace GithubSharp.Plugins.CacheProviders.WebCache 6 | { 7 | public class WebCacher : ICacheProvider 8 | { 9 | public WebCacher() 10 | { 11 | if (HttpContext.Current == null) 12 | throw new NullReferenceException("System.Web.HttpContext.Current is null"); 13 | if (HttpContext.Current.Cache == null) 14 | throw new NullReferenceException("System.Web.HttpContext.Current.Application is null"); 15 | _Cache = HttpContext.Current.Cache; 16 | } 17 | 18 | private readonly System.Web.Caching.Cache _Cache; 19 | private const string CachePrefix = "GithubSharp.Plugins.CacheProviders.WebCacher"; 20 | 21 | #region ICacheProvider implementation 22 | public T Get(string Name) 23 | where T : class 24 | { 25 | return Get(Name, DefaultDuractionInMinutes); 26 | } 27 | 28 | 29 | public T Get(string Name, int CacheDurationInMinutes) 30 | where T : class 31 | { 32 | var cached = _Cache[CachePrefix + Name] as CachedObject; 33 | if (cached == null) 34 | return null; 35 | 36 | if (cached.When.AddMinutes(CacheDurationInMinutes) < DateTime.Now) 37 | return null; 38 | 39 | return cached.Cached; 40 | } 41 | 42 | 43 | public bool IsCached(string Name) 44 | where T : class 45 | { 46 | return Get(Name) != null; 47 | } 48 | 49 | 50 | public void Set(T ObjectToCache, string Name) 51 | where T : class 52 | { 53 | var cacheObj = new CachedObject(); 54 | cacheObj.Cached = ObjectToCache; 55 | cacheObj.When = DateTime.Now; 56 | 57 | _Cache[CachePrefix + Name] = cacheObj; 58 | } 59 | 60 | 61 | public void Delete(string Name) 62 | { 63 | _Cache.Remove(CachePrefix + Name); 64 | } 65 | 66 | 67 | public void DeleteWhereStartingWith(string Name) 68 | { 69 | var enumerator = _Cache.GetEnumerator(); 70 | 71 | while (enumerator.MoveNext()) 72 | { 73 | if (enumerator.Key.ToString().StartsWith(CachePrefix + Name)) 74 | _Cache.Remove(enumerator.Key.ToString()); 75 | } 76 | } 77 | 78 | 79 | public void DeleteAll() 80 | where T : class 81 | { 82 | var enumerator = _Cache.GetEnumerator(); 83 | 84 | while (enumerator.MoveNext()) 85 | { 86 | if (enumerator.Key.ToString().StartsWith(CachePrefix)) 87 | { 88 | var obj = _Cache[enumerator.Key.ToString()] as CachedObject; 89 | if (obj != null) 90 | { 91 | _Cache.Remove(enumerator.Key.ToString()); 92 | } 93 | } 94 | } 95 | } 96 | 97 | 98 | public int DefaultDuractionInMinutes 99 | { 100 | get { return 20; } 101 | } 102 | 103 | #endregion 104 | 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Plugins/LogProviders/NullLogger/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("NullLogger")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("erikz")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /Plugins/LogProviders/NullLogger/NullLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GithubSharp.Plugins.LogProviders.NullLogger 4 | { 5 | public class NullLogger : GithubSharp.Core.Services.ILogProvider 6 | { 7 | public NullLogger () 8 | :this(false) 9 | { 10 | } 11 | 12 | public NullLogger (bool Debug) 13 | { 14 | DebugMode = Debug; 15 | } 16 | 17 | public void LogMessage (string Message, params object[] Arguments) 18 | { 19 | } 20 | 21 | public void LogWarning (string Message, params object[] Arguments) 22 | { 23 | } 24 | 25 | public bool HandleAndReturnIfToThrowError (Exception error) 26 | { 27 | return DebugMode; 28 | } 29 | 30 | public bool DebugMode { 31 | get;set; 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Plugins/LogProviders/NullLogger/NullLogger.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.0 7 | 2.0 8 | {A4F37523-CA27-4966-9BC1-51B74F77BE70} 9 | Library 10 | GithubSharp.Plugins.LogProviders.NullLogger 11 | GithubSharp.Plugins.LogProviders.NullLogger 12 | v3.5 13 | 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug 20 | DEBUG 21 | prompt 22 | 4 23 | false 24 | 25 | 26 | none 27 | false 28 | bin\Release 29 | prompt 30 | 4 31 | false 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 43 | Core %28Core\Core%29 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Plugins/LogProviders/SimpleLogProvider/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SimpleLogProvider")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SimpleLogProvider")] 13 | [assembly: AssemblyCopyright("Copyright ©")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2a112bb7-31fd-453f-bb79-7d472f10cf26")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Plugins/LogProviders/SimpleLogProvider/SimpleLogProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using GithubSharp.Core.Services; 6 | using System.IO; 7 | 8 | namespace GithubSharp.Plugins.LogProviders.SimpleLogProvider 9 | { 10 | public class SimpleLogProvider : ILogProvider 11 | { 12 | #region ILogProvider Members 13 | 14 | public bool DebugMode 15 | { 16 | get; 17 | set; 18 | } 19 | 20 | public void LogMessage(string Message, params object[] Arguments) 21 | { 22 | if (DebugMode) 23 | WriteToLog(DateTime.Now.ToString() + " " + string.Format(Message, Arguments)); 24 | } 25 | 26 | 27 | public void LogWarning(string Message, params object[] Arguments) 28 | { 29 | WriteToLog(DateTime.Now.ToString() + " " + string.Format(Message, Arguments)); 30 | } 31 | 32 | 33 | 34 | public bool HandleAndReturnIfToThrowError(Exception error) 35 | { 36 | WriteToLog(DatePrefix + " " + string.Format("{2}{0}{2}{1}{2}", error.Message, DebugMode ? error.StackTrace : "", Environment.NewLine)); 37 | return DebugMode; 38 | } 39 | 40 | #endregion 41 | 42 | private void WriteToLog(string Message) 43 | { 44 | try 45 | { 46 | if (!Directory.Exists(LogDirPath)) 47 | Directory.CreateDirectory(LogDirPath); 48 | File.AppendAllText(LogFilePath, Message, Encoding.UTF8); 49 | } 50 | catch 51 | { 52 | } 53 | } 54 | 55 | private string LogDirPath 56 | { 57 | get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"); } 58 | } 59 | private string LogFilePath 60 | { 61 | get { return Path.Combine(LogDirPath, DatePrefix); } 62 | } 63 | 64 | private string DatePrefix 65 | { 66 | get 67 | { 68 | var now = DateTime.Now; 69 | return string.Format("{0}-{1}-{2}.log", now.Day, now.Month, now.Year); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Plugins/LogProviders/SimpleLogProvider/SimpleLogProvider.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {26AB1C43-34F7-446C-A514-EB0E38730631} 9 | Library 10 | Properties 11 | GithubSharp.Plugins.LogProviders.SimpleLogProvider 12 | GithubSharp.Plugins.LogProviders.SimpleLogProvider 13 | v3.5 14 | 512 15 | 16 | 17 | 3.5 18 | 19 | false 20 | publish\ 21 | true 22 | Disk 23 | false 24 | Foreground 25 | 7 26 | Days 27 | false 28 | false 29 | true 30 | 0 31 | 1.0.0.%2a 32 | false 33 | true 34 | 35 | 36 | true 37 | full 38 | false 39 | ..\..\..\bin\ 40 | DEBUG;TRACE 41 | prompt 42 | 4 43 | AllRules.ruleset 44 | 45 | 46 | pdbonly 47 | true 48 | ..\..\..\bin\ 49 | TRACE 50 | prompt 51 | 4 52 | AllRules.ruleset 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | False 69 | .NET Framework 3.5 SP1 Client Profile 70 | false 71 | 72 | 73 | False 74 | .NET Framework 3.5 SP1 75 | true 76 | 77 | 78 | False 79 | Windows Installer 3.1 80 | true 81 | 82 | 83 | 84 | 85 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 86 | Core %28Core\Core%29 87 | 88 | 89 | 90 | 97 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | GithubSharp 2 | 3 | This project is no longer maintained. 4 | Please use the excellent https://github.com/octokit/octokit.net 5 | 6 | C# integration with Githubs v3 apis 7 | 8 | Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html 9 | -------------------------------------------------------------------------------- /Samples/ConsoleSample/ConsoleSample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {38C76F61-476B-4821-A054-E5FC54F9EDA5} 9 | Exe 10 | Properties 11 | ConsoleSample 12 | ConsoleSample 13 | v3.5 14 | 512 15 | 16 | 17 | true 18 | bin\Debug\ 19 | DEBUG;TRACE 20 | full 21 | AnyCPU 22 | bin\Debug\ConsoleSample.exe.CodeAnalysisLog.xml 23 | true 24 | GlobalSuppressions.cs 25 | prompt 26 | MinimumRecommendedRules.ruleset 27 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets 28 | false 29 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules 30 | false 31 | 4 32 | false 33 | 34 | 35 | bin\Release\ 36 | TRACE 37 | true 38 | pdbonly 39 | AnyCPU 40 | bin\Release\ConsoleSample.exe.CodeAnalysisLog.xml 41 | true 42 | GlobalSuppressions.cs 43 | prompt 44 | MinimumRecommendedRules.ruleset 45 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets 46 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules 47 | 4 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 67 | Core %28Core\Core%29 68 | 69 | 70 | {5EB1DF0E-EDBD-44EB-8A63-070F13A5D0EE} 71 | BasicCacher 72 | 73 | 74 | {26AB1C43-34F7-446C-A514-EB0E38730631} 75 | SimpleLogProvider 76 | 77 | 78 | 79 | 86 | -------------------------------------------------------------------------------- /Samples/ConsoleSample/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using GithubSharp.Core.API; 3 | using GithubSharp.Plugins.LogProviders.SimpleLogProvider; 4 | using GithubSharp.Core.Services; 5 | 6 | namespace ConsoleSample 7 | { 8 | class Program 9 | { 10 | static void Main () 11 | { 12 | //TestPullRequest (); 13 | 14 | var user = new User (new BasicCacher.BasicCacher (), new SimpleLogProvider ()); 15 | var u = user.Get ("rumpl"); 16 | Console.WriteLine (u.Blog); 17 | u = user.Get ("rumpl"); 18 | Console.WriteLine (u.Blog); 19 | 20 | user.Authenticate (new GithubSharp.Core.Models.GithubUser { Name = "erikzaadi", APIToken = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX" }); 21 | try 22 | { 23 | var privateuser = user.Get (); 24 | if (privateuser == null) 25 | throw new Exception ("Invalid user"); 26 | } 27 | catch (Exception e) 28 | { 29 | Console.WriteLine (e.Message); 30 | } 31 | 32 | 33 | var issuesAPI = new Issues(new BasicCacher.BasicCacher(), new SimpleLogProvider()); 34 | 35 | var closedIssues = issuesAPI.List("GithubSharp", "erikzaadi", GithubSharp.Core.Models.IssueState.Closed); 36 | var openIssues = issuesAPI.List("GithubSharp", "erikzaadi", GithubSharp.Core.Models.IssueState.Open); 37 | 38 | 39 | Console.ReadKey(); 40 | } 41 | 42 | private static void TestPullRequest() 43 | { 44 | var cocytusUser = new GithubSharp.Core.Models.GithubUser { Name = "cocytus", APIToken = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; 45 | PullRequest pullApi = new PullRequest(new BasicCacher.BasicCacher(), new ConsoleLogger()); 46 | var pulls = pullApi.List("spdr870", "gitextensions"); 47 | foreach (var pull in pulls) 48 | { 49 | Console.WriteLine("Pull from {1}: {0}\r\nVotes: {2}\r\nBody: {3}\r\nGravatar ID: {4}", pull.Title, pull.User.Login, pull.Votes, pull.Body, pull.User.GravatarId); 50 | Console.WriteLine("Created: {0} Updated: {1} Issue updated: {2}", pull.Created, pull.Updated, pull.IssueUpdated); 51 | Console.WriteLine("Base: Owner: {0} Name: {1} Ref: {2} Sha: {3}", pull.Base.Repository.Owner, pull.Base.Repository.Name, pull.Base.Ref, pull.Base.Sha); 52 | Console.WriteLine("Head: Owner: {0} Name: {1} Ref: {2} Sha: {3}", pull.Head.Repository.Owner, pull.Head.Repository.Name, pull.Head.Ref, pull.Head.Sha); 53 | 54 | Console.WriteLine("Diff URL: {0}\r\nPatch: {1}", pull.DiffUrl, pull.PatchUrl); 55 | Console.WriteLine("Labels: {0}", string.Join(",", pull.Labels)); 56 | Console.WriteLine("Position: {0} Number: {1}", pull.Position, pull.Number); 57 | } 58 | 59 | var pull2 = pullApi.GetById("cocytus", "gitextensions", "1"); 60 | Console.WriteLine("Pull from {1}: {0}\r\nVotes: {2}\r\nBody: {3}\r\nGravatar ID: {4}", pull2.Title, pull2.User.Login, pull2.Votes, pull2.Body, pull2.User.GravatarId); 61 | foreach (var d in pull2.Discussion) 62 | { 63 | Console.WriteLine("Discussion: From {0} At: {1} Type: {2}", d.User.Login, d.Created, d.Type); 64 | if (d.Type.ToLowerInvariant() == "commit") 65 | { 66 | Console.WriteLine("SHA/ID: {0} Body: {1}", d.Id, d.Body); 67 | } 68 | else if (d.Type.ToLowerInvariant() == "issuecomment") 69 | { 70 | Console.WriteLine("Body: {0}", d.Body); 71 | } 72 | else 73 | Console.WriteLine("WHAT? " + d.Type); 74 | } 75 | } 76 | } 77 | 78 | class ConsoleLogger : ILogProvider 79 | { 80 | public bool DebugMode { get { return true; } set{} } 81 | 82 | public void LogMessage(string Message, params object[] Arguments) 83 | { 84 | Console.WriteLine(Message, Arguments); 85 | } 86 | 87 | public void LogWarning(string Message, params object[] Arguments) 88 | { 89 | Console.WriteLine(Message, Arguments); 90 | } 91 | 92 | public bool HandleAndReturnIfToThrowError(Exception error) 93 | { 94 | LogMessage("Exception: " + error.Message); 95 | return false; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Samples/ConsoleSample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ConsoleSample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("ConsoleSample")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d2ace96a-adfe-4bc3-8b03-d03254642050")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/ConsoleSample/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Controllers/BaseAPIController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Mvc; 3 | using GithubSharp.Core.Services; 4 | 5 | namespace GithubSharp.MvcSample.MvcApplication.Controllers 6 | { 7 | public class BaseAPIController : BaseController where TApiType : Core.Base.IBaseApi 8 | { 9 | public BaseAPIController(ICacheProvider Cache, ILogProvider Log) 10 | : base(Cache, Log) 11 | { 12 | } 13 | 14 | protected virtual TApiType BaseAPI { get; set; } 15 | protected override void OnActionExecuting(ActionExecutingContext FilterContext) 16 | { 17 | BaseAPI.Authenticate(CurrentUser); 18 | base.OnActionExecuting(FilterContext); 19 | } 20 | 21 | protected virtual bool Authenticate() 22 | { 23 | var userAPI = new Core.API.User(CacheProvider, LogProvider); 24 | userAPI.Authenticate(CurrentUser); 25 | try 26 | { 27 | return userAPI.Get() != null; 28 | } 29 | catch (Exception error) 30 | { 31 | if (LogProvider.HandleAndReturnIfToThrowError(error)) 32 | throw; 33 | return false; 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Controllers/BaseController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using GithubSharp.Core.Services; 3 | using GithubSharp.MvcSample.MvcApplication.Models.ViewModels; 4 | 5 | namespace GithubSharp.MvcSample.MvcApplication.Controllers 6 | { 7 | [HandleError] 8 | public class BaseController : Controller 9 | { 10 | public BaseController(ICacheProvider Cache, ILogProvider Log) 11 | { 12 | CacheProvider = Cache; 13 | LogProvider = Log; 14 | } 15 | 16 | protected Core.Models.GithubUser CurrentUser 17 | { 18 | get 19 | { 20 | var user = Session != null ? Session["GithubUser"] : null; 21 | return user == null ? null : user as Core.Models.GithubUser; 22 | } 23 | set 24 | { 25 | Session["GithubUser"] = value; 26 | } 27 | } 28 | 29 | protected ICacheProvider CacheProvider { get; set; } 30 | 31 | protected ILogProvider LogProvider { get; set; } 32 | 33 | protected void SetTemporaryNotification(string Notification, params object[] Args) 34 | { 35 | TempData["Notification"] = string.Format(Notification, Args); 36 | } 37 | 38 | protected IBaseViewModel GetIBaseView(string Notification) 39 | { 40 | return GetBaseView(null, Notification); 41 | } 42 | 43 | protected BaseViewModel GetBaseView(T ModelParam) where T : class 44 | { 45 | return GetBaseView(ModelParam, null); 46 | } 47 | 48 | protected BaseViewModel GetBaseView(T ModelParam, string Notification) where T : class 49 | { 50 | return new BaseViewModel 51 | { 52 | CurrentUser = CurrentUser, 53 | ModelParameter = ModelParam, 54 | Notification = Notification ?? (TempData.ContainsKey("Notification") ? TempData["Notification"].ToString() : string.Empty) 55 | }; 56 | } 57 | 58 | protected override ViewResult View(IView ViewName, object Model) 59 | { 60 | if (Model == null) 61 | Model = GetBaseView(""); 62 | return base.View(ViewName, Model); 63 | } 64 | 65 | protected override ViewResult View(string ViewName, string MasterName, object Model) 66 | { 67 | if (Model == null) 68 | Model = GetBaseView(""); 69 | return base.View(ViewName, MasterName, Model); 70 | } 71 | 72 | 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Controllers/CommitController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using GithubSharp.Core.Services; 3 | 4 | namespace GithubSharp.MvcSample.MvcApplication.Controllers 5 | { 6 | public sealed class CommitController : BaseAPIController 7 | { 8 | public CommitController(ICacheProvider Cache, ILogProvider Log) 9 | : base(Cache, Log) 10 | { 11 | BaseAPI = new Core.API.Commits(Cache, Log); 12 | } 13 | 14 | public ActionResult CommitsForBranch( 15 | string Username, 16 | string RepositoryName, 17 | string BranchName) 18 | { 19 | var commits = BaseAPI.CommitsForBranch( 20 | Username, 21 | RepositoryName, 22 | BranchName); 23 | 24 | return View("Commits", GetBaseView(commits)); 25 | } 26 | 27 | public ActionResult CommitsForFile( 28 | string Username, 29 | string RepositoryName, 30 | string BranchName, 31 | string FilePath) 32 | { 33 | var commits = BaseAPI.CommitsForFile( 34 | Username, 35 | RepositoryName, 36 | BranchName, 37 | FilePath); 38 | 39 | return View("Commits", GetBaseView(commits)); 40 | } 41 | 42 | public ActionResult CommitForSingleFile( 43 | string Username, 44 | string RepositoryName, 45 | string Sha) 46 | { 47 | var commit = BaseAPI.CommitForSingleFile( 48 | Username, 49 | RepositoryName, 50 | Sha); 51 | 52 | return View("Commit", GetBaseView(commit)); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Mvc; 3 | using GithubSharp.Core.Services; 4 | using GithubSharp.Samples.MvcSample.MvcApplication.Models.ViewModels; 5 | 6 | namespace GithubSharp.MvcSample.MvcApplication.Controllers 7 | { 8 | public class HomeController : BaseController 9 | { 10 | public HomeController(ICacheProvider Cache, ILogProvider Log) 11 | : base(Cache, Log) 12 | { 13 | } 14 | 15 | public ActionResult Login(string Id) 16 | { 17 | var model = new LoginViewModel { ReturnURL = Id }; 18 | if (Request.IsAjaxRequest()) 19 | return PartialView("LoginControl", model); 20 | return View(GetBaseView(model)); 21 | } 22 | 23 | [AcceptVerbs(HttpVerbs.Post)] 24 | public ActionResult Login (string user, string Apitoken, string ReturnURL) 25 | { 26 | var userAPI = new Core.API.User (CacheProvider, LogProvider); 27 | userAPI.Authenticate (new Core.Models.GithubUser { Name = user, APIToken = Apitoken }); 28 | try 29 | { 30 | var privateuser = userAPI.Get (); 31 | if (privateuser == null) 32 | throw new Exception ("Invalid user"); 33 | 34 | CurrentUser = new Core.Models.GithubUser { Name = user, APIToken = Apitoken }; 35 | 36 | SetTemporaryNotification ("Login succeded"); 37 | 38 | if (Request.IsAjaxRequest ()) 39 | return Json (new { success = true, Name = user }); 40 | if (string.IsNullOrEmpty (ReturnURL)) 41 | return View ("Index"); 42 | return Redirect (ReturnURL); 43 | } 44 | catch (Exception error) 45 | { 46 | if (Request.IsAjaxRequest ()) 47 | return Json (new { success = false, message = error.Message }); 48 | return View (GetBaseView (new LoginViewModel { Message = error.Message, ReturnURL = ReturnURL })); 49 | } 50 | } 51 | 52 | public ActionResult Index () 53 | { 54 | return View(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Controllers/IssuesController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Web.Mvc; 3 | using GithubSharp.Core.API; 4 | using GithubSharp.Core.Models; 5 | using GithubSharp.Core.Services; 6 | 7 | namespace GithubSharp.MvcSample.MvcApplication.Controllers 8 | { 9 | public sealed class IssuesController : BaseAPIController 10 | { 11 | public IssuesController(ICacheProvider Cache, ILogProvider Log) 12 | : base(Cache, Log) 13 | { 14 | BaseAPI = new Issues(Cache, Log); 15 | } 16 | 17 | public ActionResult Search(string Id, string Username, string RepositoryName, string State) 18 | { 19 | IssueState state = State == "open" ? IssueState.Open : IssueState.Closed; 20 | IEnumerable issues = BaseAPI.Search(RepositoryName, Username, state, Id); 21 | 22 | return View("List", GetBaseView(issues)); 23 | } 24 | 25 | public ActionResult List(string Username, string RepositoryName, string State) 26 | { 27 | IssueState state = State == "open" ? IssueState.Open : IssueState.Closed; 28 | IEnumerable issues = BaseAPI.List(RepositoryName, Username, state); 29 | 30 | return View("List", GetBaseView(issues)); 31 | } 32 | 33 | public ActionResult View(string Username, string RepositoryName, int Id) 34 | { 35 | Issue issue = BaseAPI.View(RepositoryName, Username, Id); 36 | 37 | return View(GetBaseView(issue)); 38 | } 39 | 40 | public ActionResult Labels(string Username, string RepositoryName) 41 | { 42 | string[] labels = BaseAPI.Labels(RepositoryName, Username); 43 | 44 | return View(GetBaseView(labels)); 45 | } 46 | 47 | public ActionResult Comments(string Username, string RepositoryName, int Id) 48 | { 49 | IEnumerable comments = BaseAPI.Comments(RepositoryName, Username, Id); 50 | 51 | return View(GetBaseView(comments)); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Controllers/NetworkController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using GithubSharp.Core.API; 3 | using GithubSharp.Core.Services; 4 | 5 | namespace GithubSharp.MvcSample.MvcApplication.Controllers 6 | { 7 | public sealed class NetworkController : BaseAPIController 8 | { 9 | public NetworkController(ICacheProvider CacheProvider, ILogProvider LogProvider) 10 | : base(CacheProvider, LogProvider) 11 | { 12 | BaseAPI = new Network(CacheProvider, LogProvider); 13 | } 14 | 15 | [AcceptVerbs(HttpVerbs.Get)] 16 | public ActionResult Index() 17 | { 18 | var meta = BaseAPI.Meta(CurrentUser.Name, "Swahili"); 19 | return View(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Controllers/ObjectController.cs: -------------------------------------------------------------------------------- 1 | using GithubSharp.Core.Services; 2 | 3 | namespace GithubSharp.MvcSample.MvcApplication.Controllers 4 | { 5 | public sealed class ObjectController : BaseAPIController 6 | { 7 | public ObjectController(ICacheProvider Cache, ILogProvider Log) 8 | : base(Cache, Log) 9 | { 10 | BaseAPI = new Core.API.Object(Cache, Log); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Controllers/UserController.cs: -------------------------------------------------------------------------------- 1 | using GithubSharp.Core.Services; 2 | 3 | namespace GithubSharp.MvcSample.MvcApplication.Controllers 4 | { 5 | public sealed class UserController : BaseAPIController 6 | { 7 | public UserController(ICacheProvider Cache, ILogProvider Log) 8 | : base(Cache, Log) 9 | { 10 | BaseAPI = new Core.API.User(Cache, Log); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Default.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | using System.Web; 4 | using System.Web.Mvc; 5 | namespace GithubSharp.MvcSample.MvcApplication 6 | { 7 | public class Default : Page 8 | { 9 | public void Page_Load (object sender, System.EventArgs e) 10 | { 11 | // Change the current path so that the Routing handler can correctly interpret 12 | // the request, then restore the original path so that the OutputCache module 13 | // can correctly process the response (if caching is enabled). 14 | 15 | string originalPath = Request.Path; 16 | HttpContext.Current.RewritePath (Request.ApplicationPath, false); 17 | IHttpHandler httpHandler = new MvcHttpHandler (); 18 | httpHandler.ProcessRequest (HttpContext.Current); 19 | HttpContext.Current.RewritePath (originalPath, false); 20 | } 21 | } 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Models/HtmlHelpers/AdditionalHtmlAndUrlHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Text; 7 | using System.Web.WebPages; 8 | 9 | namespace GithubSharp.Samples.MvcSample.MvcApplication.Models.HtmlHelpers 10 | { 11 | public static class AdditionalHtmlAndUrlHelpers 12 | { 13 | 14 | public static MvcHtmlString If (this HtmlHelper helper, bool condition, Func trueAction) 15 | { 16 | return If (condition, () => MvcHtmlString.Create (trueAction ()), null); 17 | } 18 | 19 | public static MvcHtmlString If (this HtmlHelper helper, bool condition, Func trueAction) 20 | { 21 | return If (condition, trueAction, null); 22 | } 23 | 24 | public static MvcHtmlString If (this HtmlHelper helper, bool condition, Func trueAction, Func elseAction) 25 | { 26 | return If (condition, trueAction, () => elseAction == null ? MvcHtmlString.Empty : MvcHtmlString.Create (elseAction ())); 27 | } 28 | public static MvcHtmlString If (this HtmlHelper helper, bool condition, Func trueAction, Func elseAction) 29 | { 30 | return If (condition, trueAction, elseAction); 31 | } 32 | public static MvcHtmlString If (this HtmlHelper helper, bool condition, Func trueAction, Func elseAction) 33 | { 34 | return If (condition, () => MvcHtmlString.Create (trueAction ()), elseAction); 35 | } 36 | public static MvcHtmlString If (this HtmlHelper helper, bool condition, Func trueAction, Func elseAction) 37 | { 38 | return If (condition, () => MvcHtmlString.Create (trueAction ()), () => elseAction == null ? MvcHtmlString.Empty : MvcHtmlString.Create (elseAction ())); 39 | } 40 | 41 | 42 | private static MvcHtmlString If (bool condition, Func trueAction, Func elseAction) 43 | { 44 | if (condition) 45 | return trueAction (); 46 | if (elseAction == null) 47 | return MvcHtmlString.Empty; 48 | return elseAction (); 49 | } 50 | 51 | private static readonly object _o = new object (); 52 | public static HelperResult RenderSection (this WebPageBase page, string sectionName, Func defaultContent) 53 | { 54 | if (page.IsSectionDefined (sectionName)) { 55 | return page.RenderSection (sectionName); 56 | } else { 57 | return defaultContent (_o); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Models/ViewModels/BaseViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace GithubSharp.MvcSample.MvcApplication.Models.ViewModels 2 | { 3 | public class BaseViewModel : IBaseViewModel where T : class 4 | { 5 | public Core.Models.GithubUser CurrentUser { get; set; } 6 | public T ModelParameter { get; set; } 7 | public string Notification { get; set; } 8 | } 9 | 10 | public interface IBaseViewModel 11 | { 12 | Core.Models.GithubUser CurrentUser { get; set; } 13 | string Notification { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Models/ViewModels/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using System.Collections.Generic; 4 | using GithubSharp.MvcSample.MvcApplication.Models.ViewModels; 5 | 6 | namespace GithubSharp.Samples.MvcSample.MvcApplication.Models.ViewModels 7 | { 8 | public class ErrorViewModel : System.Web.Mvc.HandleErrorInfo, IBaseViewModel 9 | { 10 | #region IBaseViewModel implementation 11 | public GithubSharp.Core.Models.GithubUser CurrentUser 12 | { 13 | get 14 | { 15 | var user = System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Session != null ? System.Web.HttpContext.Current.Session["GithubUser"] : null; 16 | return user == null ? null : user as GithubSharp.Core.Models.GithubUser; 17 | } 18 | set 19 | { 20 | System.Web.HttpContext.Current.Session["GithubUser"] = value; 21 | } 22 | } 23 | 24 | public string Notification { get; set; } 25 | 26 | #endregion 27 | public ErrorViewModel(Exception exception, string controller, string action) : base(exception, controller, action) 28 | { 29 | } 30 | 31 | 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Models/ViewModels/LoginViewModel.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | 4 | namespace GithubSharp.Samples.MvcSample.MvcApplication.Models.ViewModels 5 | { 6 | public class LoginViewModel 7 | { 8 | 9 | public string Message { 10 | get; 11 | set; 12 | } 13 | 14 | public string ReturnURL { 15 | get; 16 | set; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MvcApplication")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MvcApplication")] 13 | [assembly: AssemblyCopyright("Copyright © 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a266ef1c-8f1c-4f8e-94eb-5f7ebadc117f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcApplication/ServerApp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | using System.Reflection; 8 | using System.Web; 9 | 10 | namespace GithubSharp.MvcSample.MvcApplication 11 | { 12 | public class ServerApp : HttpApplication 13 | { 14 | public static void RegisterGlobalFilters (GlobalFilterCollection filters) 15 | { 16 | filters.Add (new HandleErrorAttribute ()); 17 | } 18 | 19 | public static void RegisterRoutes (RouteCollection routes) 20 | { 21 | routes.IgnoreRoute ("{resource}.axd/{*pathInfo}"); 22 | routes.IgnoreRoute ("favicon.ico"); 23 | routes.IgnoreRoute ("robots.txt"); 24 | 25 | // Route name 26 | // URL with parameters 27 | // Parameter defaults 28 | routes.MapRoute ("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" }); 29 | 30 | } 31 | 32 | protected void Application_Start () 33 | { 34 | 35 | AreaRegistration.RegisterAllAreas (); 36 | RegisterGlobalFilters (GlobalFilters.Filters); 37 | RegisterRoutes (RouteTable.Routes); 38 | 39 | DependencyResolver.SetResolver (new Munq.MVC3.MunqDependencyResolver ()); 40 | 41 | Munq.MVC3.MunqDependencyResolver.Container.RegisterInstance (new GithubSharp.Plugins.CacheProviders.WebCache.WebCacher ()); 42 | 43 | 44 | Munq.MVC3.MunqDependencyResolver.Container.RegisterInstance (new GithubSharp.Plugins.LogProviders.SimpleLogProvider.SimpleLogProvider ()); 45 | 46 | 47 | 48 | 49 | //kernel.Bind ().To (); 50 | //kernel.Bind ().To (); 51 | 52 | } 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="GithubSharp.MvcSample.MvcApplication.Default" %> -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Inherits="GithubSharp.MvcSample.MvcApplication.ServerApp" Language="C#" %> 2 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MvcUI")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MvcUI")] 13 | [assembly: AssemblyCopyright("Copyright © 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("12a4f630-b2eb-463e-9b11-d0c0955e635f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Commit/Commit.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>" %> 2 | 3 | 4 | Commit 5 | 6 | 7 |

8 | Commit

9 | <% if (Model != null && Model.ModelParameter != null) 10 | { 11 | Html.RenderPartial("CommitRenderer", Model.ModelParameter); 12 | } 13 | else 14 | { %> 15 | No commit found.. 16 | <%} %> 17 |
18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Commit/CommitRenderer.ascx: -------------------------------------------------------------------------------- 1 | <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> 2 |
3 | Fields 4 |
5 | url
6 |
7 | <%= Html.Encode(Model.URL) %>
8 |
9 | id
10 |
11 | <%= Html.Encode(Model.Id) %>
12 |
13 | committed_date
14 |
15 | <%= Html.Encode(String.Format("{0:g}", Model.CommittedDate)) %>
16 |
17 | authored_date
18 |
19 | <%= Html.Encode(String.Format("{0:g}", Model.AuthoredDate)) %>
20 |
21 | message
22 |
23 | <%= Html.Encode(Model.Message) %>
24 |
25 | tree
26 |
27 | <%= Html.Encode(Model.Tree) %>
28 | <% if (Model is GithubSharp.Core.Models.SingleFileCommit) 29 | { 30 | var single = Model as GithubSharp.Core.Models.SingleFileCommit; 31 | %> 32 |
33 |

34 | File information : 35 |

36 |
37 |

38 | Added:

39 | <% 40 | single.Added.ToList().ForEach(added => 41 | Html.RenderPartial("SingleFileCommitRenderer", added)); %> 42 |
43 |
44 |

45 | Removed:

46 | <% 47 | single.Removed.ToList().ForEach(removed => 48 | Html.RenderPartial("SingleFileCommitRenderer", removed)); %> 49 |
50 |
51 |

52 | Modified:

53 | <% 54 | single.Modified.ToList().ForEach(modified => 55 | Html.RenderPartial("SingleFileCommitRenderer", modified)); %> 56 |
57 |
58 | <% 59 | } 60 | else 61 | { 62 | %> 63 |
64 | <%= Html.ActionLink("Commit details", "CommitForSingleFile", "Commit", new { Username = Model.Committer.Login, RepositoryName = Request["RepositoryName"], Sha = Model.Id }, null)%> 65 |
66 | <% 67 | } %> 68 |
69 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Commit/Commits.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>>" %> 2 | 3 | 4 | Commits 5 | 6 | 7 |

8 | Commits

9 | <% if (Model != null && Model.ModelParameter != null) 10 | { 11 | Model.ModelParameter.ToList().ForEach(commit => 12 | { %> 13 |
14 |
15 | <% Html.RenderPartial("CommitRenderer", commit); %> 16 |
17 | <%}); 18 | } 19 | else 20 | { %> 21 | No commits found.. 22 | <%} %> 23 |
24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Commit/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Index 5 | 6 | 7 | 8 | 9 |

Index

10 | 11 |
12 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Commit/SingleFileCommitRenderer.ascx: -------------------------------------------------------------------------------- 1 | <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> 2 |
3 | filename : 4 | <%= Html.Encode(Model.Filename) %> 5 |
6 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Gists/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Index 5 | 6 | 7 | 8 | 9 |

Index

10 | 11 |
12 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Home/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Home Page 5 | 6 | 7 |

8 | Welcome to the Github Sharp sample Project 9 |

10 |

11 | Click on the links to browse the various api's 12 |

13 |
14 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Issues/Comments.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>>" %> 2 | 3 | 4 | Comments 5 | 6 | 7 |

8 | Comments

9 | <% if (Model.ModelParameter != null && Model.ModelParameter.Count() > 0) 10 | { %> 11 |
    12 | <% foreach (var comment in Model.ModelParameter) 13 | { %> 14 |
  • 15 |
    16 |
    17 | #<%= comment.Id%>
    18 |
    19 | <%= Html.Encode(comment.Body)%>
    20 |
    21 | Created : 22 | <%= comment.CreatedAt%> 23 | by : 24 | <%= comment.User%>
    25 |
    26 |
  • 27 | <%} %> 28 |
29 | <%} 30 | else 31 | { %> 32 |

33 | No comments found

34 | <%} %> 35 |
36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Issues/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Index 5 | 6 | 7 | 8 | 9 |

Index

10 | 11 |
12 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Issues/Issue.ascx: -------------------------------------------------------------------------------- 1 | <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> 2 |
3 |
4 | <%= Html.Encode(Model.Title) %> 5 | #<%= Model.Number%>
6 |
7 | <%= Html.Encode(Model.Body)%>
8 |
9 | Created : 10 | <%= Model.CreatedAt%> 11 | , State : 12 | <%= Model.State %> 13 | <%-- == GithubSharp.Core.Models.IssueState.Closed ? "closed" : "open" --%>
14 |
15 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Issues/Labels.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>" %> 2 | 3 | 4 | Labels 5 | 6 | 7 |

8 | Labels

9 | <% if (Model.ModelParameter != null && Model.ModelParameter.Count() > 0) 10 | { %> 11 |
    12 | <% foreach (var label in Model.ModelParameter) 13 | { %> 14 |
  • 15 | <%= label %> 16 |
  • 17 | <%} %> 18 |
19 | <%} 20 | else 21 | { %> 22 |

23 | No labels found

24 | <%} %> 25 |
26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Issues/List.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>>" %> 2 | 3 | 4 | List 5 | 6 | 7 |

8 | List

9 | <% if (Model.ModelParameter != null && Model.ModelParameter.Count() > 0) 10 | {%> 11 |
    12 | <% 13 | foreach (var issue in Model.ModelParameter) 14 | { 15 | %> 16 |
  • 17 | <% Html.RenderPartial("Issue", issue); %> 18 |
  • 19 | <%} %> 20 |
21 | <% 22 | } 23 | else 24 | { %> 25 |

26 | No issues found

27 | <%} %> 28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Issues/View.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>" %> 2 | 3 | 4 | View 5 | 6 | 7 |

8 | View

9 | <% Html.RenderPartial("Issue", Model.ModelParameter); %> 10 |
11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Network/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Index 5 | 6 | 7 | 8 | 9 |

Index

10 | 11 |
12 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Object/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Index 5 | 6 | 7 | 8 | 9 |

Index

10 | 11 |
12 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Repository/Branches.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>>" %> 2 | 3 | 4 | Branches 5 | 6 | 7 |

8 | Branches

9 |
    10 | <% foreach (var lang in Model.ModelParameter) 11 | { %> 12 |
  • 13 |
    14 | Name:<%= lang.Name %>
    15 |
    16 | Sha:<%= lang.Sha %>
    17 |
  • 18 | <%} %> 19 |
20 |
21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Repository/Create.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>" %> 2 | 3 | 4 | Create Repository 5 | 6 | 7 |

8 | Create

9 | <%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %> 10 | <% using (Html.BeginForm()) 11 | {%> 12 |
13 | Fields 14 |

15 | 17 | <%= Html.TextBox("RepositoryName")%> 18 | <%= Html.ValidationMessage("RepositoryName", "*")%> 19 |

20 |

21 | 23 | <%= Html.TextArea("Description")%> 24 |

25 |

26 | 28 | <%= Html.TextBox("HomePage")%> 29 |

30 |

31 | 33 | <%= Html.CheckBox("Public")%> 34 |

35 |

36 | 37 |

38 |
39 | <% } %> 40 |
41 | <%=Html.ActionLink("Back to List", "Index") %> 42 |
43 |
44 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Repository/Delete.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>" %> 2 | 3 | 4 | Delete Repository 5 | 6 | 7 |

8 | Delete Repository - 9 | <%= Model.ModelParameter %>

10 |
11 | Are you sure you want to delete '<%= Model.ModelParameter %>'?
12 | <% using (Html.BeginForm()) 13 | { %> 14 | <%--= Html.AntiForgeryToken() Doesn't work on mono :( --%> 15 | <%= Html.Hidden("RepositoryName", Model.ModelParameter )%> 16 | <%= Html.CheckBox("Delete") %> 17 | 19 | <%} %> 20 | <%= Html.ActionLink("Get me out of here!", "Index") %> 21 |
22 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Repository/Get.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.master" Inherits="System.Web.Mvc.ViewPage>" %> 2 | 3 | 4 | Get 5 | 6 | 7 |

8 | Repository Details

9 |

10 | <%=Html.ActionLink("Back to Search", "Index") %> 11 | <%= Html.If(Model.CurrentUser != null && Model.ModelParameter.Owner == Model.CurrentUser.Name, ()=> 12 | string.Format(" | {0} | {1} ", 13 | Html.ActionLink("Delete", "Delete", new { RepositoryName = Model.ModelParameter.Name, Username = Model.ModelParameter.Owner }) , 14 | Html.ActionLink("Edit", "Edit", new { /* id=Model.ModelParameter.PrimaryKey */ })), ()=> Html.ActionLink("Fork", "Fork", new {RepositoryName = Model.ModelParameter.Name , Username = Model.ModelParameter.Owner})) %> 15 |

16 |
17 | Fields 18 |

19 | url: 20 | <%= Html.Encode(Model.ModelParameter.URL) %> 21 |

22 |

23 | description: 24 | <%= Html.Encode(Model.ModelParameter.Description) %> 25 |

26 |

27 | homepage: 28 | <%= Html.Encode(Model.ModelParameter.Homepage) %> 29 |

30 |

31 | name: 32 | <%= Html.Encode(Model.ModelParameter.Name) %> 33 |

34 |

35 | owner: 36 | <%= Html.Encode(Model.ModelParameter.Owner) %> 37 |

38 |

39 | fork: 40 | <%= Html.Encode(Model.ModelParameter.Fork) %> 41 |

42 |

43 | private: 44 | <%= Html.Encode(Model.ModelParameter.Private) %> 45 |

46 |

47 | open_issues: 48 | <%= Html.Encode(Model.ModelParameter.OpenIssues) %> 49 |

50 |

51 | watchers: 52 | <%= Html.Encode(Model.ModelParameter.Watchers) %> 53 |

54 |

55 | forks: 56 | <%= Html.Encode(Model.ModelParameter.Forks) %> 57 |

58 |

59 | WatchersURL: 60 | <%= Html.Encode(Model.ModelParameter.WatchersURL) %> 61 |

62 |

63 | DownloadURL: 64 | <%= Html.Encode(Model.ModelParameter.DownloadURL) %> 65 |

66 |

67 | ForksURL: 68 | <%= Html.Encode(Model.ModelParameter.ForksURL) %> 69 |

70 |

71 | IssuesURL: 72 | <%= Html.Encode(Model.ModelParameter.IssuesURL) %> 73 |

74 |

75 | WikiURL: 76 | <%= Html.Encode(Model.ModelParameter.WikiURL) %> 77 |

78 |

79 | GraphsURL: 80 | <%= Html.Encode(Model.ModelParameter.GraphsURL) %> 81 |

82 |

83 | ForkQuoueURL: 84 | <%= Html.Encode(Model.ModelParameter.ForkQuoueURL) %> 85 |

86 |

87 | GitCloneURL: 88 | <%= Html.Encode(Model.ModelParameter.GitCloneURL) %> 89 |

90 |

91 | HttpCloneURL: 92 | <%= Html.Encode(Model.ModelParameter.HttpCloneURL) %> 93 |

94 |

95 | ForkURL: 96 | <%= Html.Encode(Model.ModelParameter.ForkURL) %> 97 |

98 |

99 | WatchURL: 100 | <%= Html.Encode(Model.ModelParameter.WatchURL) %> 101 |

102 |
103 |
104 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Repository/Languages.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>>" %> 2 | 3 | 4 | Languages 5 | 6 | 7 |

8 | Languages

9 |
    10 | <% foreach (var lang in Model.ModelParameter) 11 | { %> 12 |
  • 13 |
    14 | Name:<%= lang.Name %>
    15 |
    16 | CalculatedBytes:<%= lang.CalculatedBytes %>
    17 |
  • 18 | <%} %> 19 |
20 |
21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Repository/Network.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>>" %> 2 | 3 | 4 | Network 5 | 6 | 7 |

8 | Network

9 | <% 10 | if (Model.ModelParameter != null && Model.ModelParameter.Count() > 0) 11 | { %> 12 |
    13 | <% 14 | foreach (var network in Model.ModelParameter) 15 | { %> 16 |
  • 17 |
    18 | Name:<%= network.Name%>
    19 |
    20 | Owner:<%= network.Owner%>
    21 |
  • 22 | <%}%> 23 |
24 | <% 25 | } 26 | else 27 | {%> 28 |

29 | No forks found..

30 | <%} %> 31 |
32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Repository/PublicKeys.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>>" %> 2 | 3 | 4 | PublicKeys 5 | 6 | 7 |

8 | PublicKeys

9 | <% if (Model.ModelParameter != null && Model.ModelParameter.Count() > 0) 10 | { %> 11 | 12 | 13 | 15 | 18 | 21 | 24 | 25 | <% foreach (var item in Model.ModelParameter) 26 | { %> 27 | 28 | 32 | 35 | 38 | 41 | 42 | <% } %> 43 |
14 | 16 | title 17 | 19 | id 20 | 22 | key 23 |
29 | <%= Html.ActionLink("Edit", "EditPublicKey", new { id = item.Id })%> 30 | | 31 | 33 | <%= Html.Encode(item.Title)%> 34 | 36 | <%= Html.Encode(item.Id)%> 37 | 39 | <%= Html.Encode(item.Key)%> 40 |
44 | <%} 45 | else 46 | { %> 47 |
48 | No public keys available
49 | <%} %> 50 |

51 | <%= Html.ActionLink("Create New Public Key", "CreatePublicKey") %> 52 |

53 |
54 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Repository/Search.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.master" Inherits="System.Web.Mvc.ViewPage>>" %> 2 | 3 | 4 | Search 5 | 6 | 7 |

8 | Search

9 | <% using (Html.BeginForm(new { action = "Search" })) 10 | { %> 11 | <%= Html.TextBox("id")%> 12 | 14 |
15 | <%= Html.ActionLink("Create New","Create") %>
16 | <%} %> 17 |
18 | <% if (Model.ModelParameter != null && Model.ModelParameter.Count() > 0) 19 | { 20 | Model.ModelParameter.ToList().ForEach(repo => 21 | { %> 22 |

23 | <%= repo.Name %>

24 |

25 | <%= repo.Description%>

26 |

27 | <%= Html.ActionLink(repo.Username, "List", new {id=repo.Username})%>

28 |
29 | <%= Html.ActionLink("Details", "Get", new {RepositoryName = repo.Name, Username=repo.Username}) %>
30 | <%}); 31 | } %> 32 |
33 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Repository/Tags.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>>" %> 2 | 3 | 4 | Tags 5 | 6 | 7 |

8 | Tags

9 | <% 10 | if (Model.ModelParameter != null && Model.ModelParameter.Count() > 0) 11 | { %> 12 |
    13 | <% 14 | foreach (var lang in Model.ModelParameter) 15 | { %> 16 |
  • 17 |
    18 | Name:<%= lang.Name%>
    19 |
    20 | Sha:<%= lang.Sha%>
    21 |
  • 22 | <%}%> 23 |
24 | <% 25 | } 26 | else 27 | {%> 28 |

29 | No tags found..

30 | <%} %> 31 |
32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model GithubSharp.Samples.MvcSample.MvcApplication.Models.ViewModels.ErrorViewModel 2 | @section Title { 3 | Error 4 | } 5 |

6 | Sorry, an error occurred while processing your request. 7 |

8 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Shared/Footer.cshtml: -------------------------------------------------------------------------------- 1 | Copyright 2011 Erik Zaadi -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Shared/Login.cshtml: -------------------------------------------------------------------------------- 1 | @model GithubSharp.MvcSample.MvcApplication.Models.ViewModels.BaseViewModel 2 | @Html.RenderPartial("LoginControl", Model.ModelParameter) 3 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Shared/LoginControl.cshtml: -------------------------------------------------------------------------------- 1 | @model GithubSharp.Samples.MvcSample.MvcApplication.Models.ViewModels.LoginViewModel 2 | 30 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Shared/LoginDisplay.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | var show = ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString() != "Login"; 3 | } 4 |
5 |   6 | @if (show) { 7 | if(Model == null || Model.CurrentUser == null){ 8 | @Html.ActionLink("Login", "Login", "Home") 9 | } else { 10 | @Model.CurrentUser.Name @Html.ActionLink("Change", "Login", "Home")) 11 | } 12 | } 13 |
14 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Shared/Menu.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | var currentController = ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(); 3 | Func currentOrNot = (string x) => { return currentController == x ? "CurrentAPI" : ""; }; 4 | 5 | } 6 | 22 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | @RenderSection("Title", "GithubSharp") 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 |
18 |
19 |  
20 | 33 |
34 |
35 | @if (Model != null && !string.IsNullOrEmpty(Model.Notification)) 36 | { 37 | 38 | @Model.Notification%> 39 | } 40 |
41 |
42 | @RenderBody() 43 |
44 | 47 |
48 |
49 |
50 | @Html.RenderPartial("LoginControl", new GithubSharp.Samples.MvcSample.MvcApplication.Models.ViewModels.LoginViewModel()) 51 |
52 | 53 | 54 | @RenderSection("ScriptsIncludes", false) 55 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/User/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Index 5 | 6 | 7 | 8 | 9 |

Index

10 | 11 |
12 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @model GithubSharp.MvcSample.MvcApplication.Models.ViewModels.IBaseViewModel 2 | @{ 3 | Layout = "~/Views/Shared/_Layout.cshtml"; 4 | } 5 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/css/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Samples/MvcSample/MvcUI/css/grid.png -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/css/ie.min.css: -------------------------------------------------------------------------------- 1 | body{text-align:center;}.container{text-align:left;}* html .column,* html .span-1,* html .span-2,* html .span-3,* html .span-4,* html .span-5,* html .span-6,* html .span-7,* html .span-8,* html .span-9,* html .span-10,* html .span-11,* html .span-12,* html .span-13,* html .span-14,* html .span-15,* html .span-16,* html .span-17,* html .span-18,* html .span-19,* html .span-20,* html .span-21,* html .span-22,* html .span-23,* html .span-24{display:inline;overflow-x:hidden;} 2 | * html legend{margin:0 -8px 16px 0;padding:0;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;} 3 | html>body p code{*white-space:normal;}hr{margin:-8px auto 11px;}img{-ms-interpolation-mode:bicubic;} 4 | .clearfix,.container{display:inline-block;}* html .clearfix,* html .container{height:1%;} 5 | fieldset{padding-top:0;}textarea{overflow:auto;}input.text,input.title,textarea{background-color:#fff;border:1px solid #bbb;} 6 | input.text:focus,input.title:focus{border-color:#666;}input.text,input.title,textarea,select{margin:.5em 0;} 7 | input.checkbox,input.radio{position:relative;top:.25em;}form.inline div,form.inline p{vertical-align:middle;} 8 | form.inline label{position:relative;top:-0.25em;}form.inline input.checkbox,form.inline input.radio,form.inline input.button,form.inline button{margin:.5em 0;} 9 | button,input.button{position:relative;top:.25em;} -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/css/main.css: -------------------------------------------------------------------------------- 1 | #menu 2 | { 3 | display: block; 4 | float: left; 5 | list-style: none; 6 | } 7 | #menu li 8 | { 9 | float: left; 10 | display: block; 11 | padding: 15px; 12 | } 13 | #menu li a:hover 14 | { 15 | border: solid thin silver; 16 | margin: -1px; 17 | } 18 | .CurrentAPI 19 | { 20 | background: #FAFAFA !important; 21 | border: solid thin #CCC !important; 22 | color: Navy !important; 23 | -webkit-border-radius: 3px 3px 3px 3px; 24 | border-radius: 3px 3px 3px 3px; 25 | -moz-border-radius: 3px 3px 3px 3px; 26 | padding: 5px !important; 27 | margin: -5px !important; 28 | } 29 | .CurrentAPI:hover 30 | { 31 | background: #CACACA !important; 32 | color: #FAFAFA !important; 33 | } 34 | #logindisplay 35 | { 36 | margin-top: 10px; 37 | } 38 | .login 39 | { 40 | text-align: left; 41 | } 42 | .login legend 43 | { 44 | padding: 5px; 45 | } 46 | .login fieldset 47 | { 48 | border: solid thin black; 49 | -webkit-border-radius: 3px 3px 3px 3px; 50 | border-radius: 3px 3px 3px 3px; 51 | -moz-border-radius: 3px 3px 3px 3px; 52 | padding: 5px; 53 | width: 340px; 54 | } 55 | .login div span 56 | { 57 | display: block; 58 | float: left; 59 | margin-top: 5px; 60 | width: 75px; 61 | } 62 | .login div 63 | { 64 | float: none; 65 | clear: both; 66 | } 67 | #errormessage 68 | { 69 | width: 0; 70 | overflow: visible; 71 | } 72 | #blocker 73 | { 74 | background-color: #FFF; 75 | border-radius: 3px; 76 | -moz-border-radius: 3px; 77 | -webkit-border-radius: 3px; 78 | border: solid 3px #FCFCFC; 79 | left: 35%; 80 | margin: 0; 81 | padding: 5px; 82 | position: fixed; 83 | text-align: center; 84 | top: 20px; 85 | z-index: 1001; 86 | display: none; 87 | } 88 | .overlayed 89 | { 90 | border: medium none; 91 | cursor: wait; 92 | height: 100%; 93 | left: 0; 94 | margin: 0; 95 | padding: 0; 96 | position: fixed; 97 | top: 0; 98 | width: 100%; 99 | z-index: 1000; 100 | } 101 | .overlayedReady 102 | { 103 | background-color: #666; 104 | } 105 | -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/css/main.min.css: -------------------------------------------------------------------------------- 1 | #menu{display:block;float:left;list-style:none;}#menu li{float:left;display:block;padding:15px;} 2 | #menu li a:hover{border:solid thin silver;margin:-1px;}.CurrentAPI{background:#FAFAFA!important;border:solid thin #CCC!important;color:Navy!important;-webkit-border-radius:3px 3px 3px 3px;border-radius:3px 3px 3px 3px;-moz-border-radius:3px 3px 3px 3px;padding:5px!important;margin:-5px!important;} 3 | .CurrentAPI:hover{background:#CACACA!important;color:#FAFAFA!important;}#logindisplay{margin-top:10px;} 4 | .login{text-align:left;}.login legend{padding:5px;}.login fieldset{border:solid thin black;-webkit-border-radius:3px 3px 3px 3px;border-radius:3px 3px 3px 3px;-moz-border-radius:3px 3px 3px 3px;padding:5px;width:340px;} 5 | .login div span{display:block;float:left;margin-top:5px;width:75px;}.login div{float:none;clear:both;} 6 | #errormessage{width:0;overflow:visible;}#blocker{background-color:#FFF;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;border:solid 3px #FCFCFC;left:35%;margin:0;padding:5px;position:fixed;text-align:center;top:20px;z-index:1001;display:none;} 7 | .overlayed{border:medium none;cursor:wait;height:100%;left:0;margin:0;padding:0;position:fixed;top:0;width:100%;z-index:1000;} 8 | .overlayedReady{background-color:#666;} -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Samples/MvcSample/MvcUI/images/favicon.ico -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/images/githubsharp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikzaadi/GithubSharp/c13cb166fdbabfe9ff0abbef48da674ecab96b06/Samples/MvcSample/MvcUI/images/githubsharp.png -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/js/main.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | var UrlHelper = 5 | { 6 | Base: '', 7 | LoginURL: function() { return this.Base + 'Home/Login'; } 8 | }; 9 | 10 | function InitMaster(BaseURL) { 11 | UrlHelper.Base = BaseURL; 12 | $("#logindisplay a").live('click', LoginPopup); 13 | RemoveNotification(); 14 | InitPopup(); 15 | } 16 | 17 | function InitPopup() { 18 | var $blocker = $("#blocker"); 19 | $('').insertAfter("#blocker input[type='submit']"); 20 | $("#CancelButton", $blocker).click(function() { 21 | $blocker.slideUp('fast'); 22 | $(".overlayed").remove(); 23 | return false; 24 | }); 25 | } 26 | 27 | function RemoveNotification() { 28 | setTimeout(function() { $("#notification").fadeOut('slow'); }, 3500); 29 | } 30 | 31 | function LoginPopup() { 32 | var $blocker = $("#blocker"); 33 | $("form", $blocker).submit(function() { 34 | $.post(UrlHelper.LoginURL(), $(this).serialize(), function(data) { 35 | if (data) { 36 | if (data.success) { 37 | $blocker.slideUp('fast'); 38 | $(".overlayed").remove(); 39 | $("#logindisplay").html(data.Name + ' Change'); 40 | $("#notificationwrapper").html('Login succeeded'); 41 | RemoveNotification(); 42 | } 43 | else { 44 | $("#errormessage", $blocker).html('' + data.message + ''); 45 | } 46 | } 47 | }, "json"); 48 | return false; 49 | }); 50 | $('
').appendTo("body").fadeTo('slow', 0.4, function() { 51 | $(this).toggleClass('overlayedReady', true); 52 | $blocker.slideDown('fast'); 53 | }); 54 | 55 | return false; 56 | } -------------------------------------------------------------------------------- /Samples/MvcSample/MvcUI/js/main.min.js: -------------------------------------------------------------------------------- 1 | var UrlHelper={Base:"",LoginURL:function(){return this.Base+"Home/Login"}};function InitMaster(a){UrlHelper.Base=a;$("#logindisplay a").live("click",LoginPopup);RemoveNotification();InitPopup()}function InitPopup(){var a=$("#blocker");$('').insertAfter("#blocker input[type='submit']");$("#CancelButton",a).click(function(){a.slideUp("fast");$(".overlayed").remove();return false})} 2 | function RemoveNotification(){setTimeout(function(){$("#notification").fadeOut("slow")},3500)} 3 | function LoginPopup(){var a=$("#blocker");$("form",a).submit(function(){$.post(UrlHelper.LoginURL(),$(this).serialize(),function(b){if(b)if(b.success){a.slideUp("fast");$(".overlayed").remove();$("#logindisplay").html(b.Name+' Change');$("#notificationwrapper").html('Login succeeded');RemoveNotification()}else $("#errormessage",a).html(''+b.message+"")},"json");return false});$('
').appendTo("body").fadeTo("slow", 4 | 0.4,function(){$(this).toggleClass("overlayedReady",true);a.slideDown("fast")});return false}; 5 | -------------------------------------------------------------------------------- /Tests/CoreTests/CoreTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.0 7 | 2.0 8 | {EF80C27A-4AE0-4B92-8270-B44D66996801} 9 | Library 10 | GithubSharp.Tests.CoreTests 11 | GithubSharp.Tests.CoreTests 12 | v3.5 13 | 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug 20 | DEBUG 21 | prompt 22 | 4 23 | false 24 | 25 | 26 | none 27 | false 28 | bin\Release 29 | prompt 30 | 4 31 | false 32 | 33 | 34 | 35 | 36 | ..\..\Libs\nunit\nunit.framework.dll 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | {59C24364-8C00-46AD-9CE6-1D5630656DF9} 47 | Core %28Core\Core%29 48 | 49 | 50 | {3C916941-003B-480E-9981-2B9FEFFBF447} 51 | NullAuthProvider 52 | 53 | 54 | {61EFFFA9-0713-47CA-95D9-193E16BBA3B9} 55 | UserPasswordAuthProvider 56 | 57 | 58 | {D2AA69DA-E0F8-4583-B161-48E763DB8D23} 59 | NullCacher 60 | 61 | 62 | {A4F37523-CA27-4966-9BC1-51B74F77BE70} 63 | NullLogger 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Tests/CoreTests/TestSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace CoreTests 4 | { 5 | public class TestSettings 6 | { 7 | public static string Username { 8 | get { return "erikzaadi";} //change to your user 9 | } 10 | 11 | public static string Password { 12 | get { return "No, I won't put my password here"; } //change to your password 13 | } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /build: -------------------------------------------------------------------------------- 1 | xbuild GithubSharp.sln 2 | -------------------------------------------------------------------------------- /nuget/GithubSharp.Core.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GithubSharp.Core 5 | 0.0.5.1 6 | Erik Zaadi 7 | 8 | C# integration with Githubs v2 apis - Core Module 9 | 10 | http://github.com/erikzaadi/GithubSharp 11 | https://github.com/erikzaadi/GithubSharp/raw/master/Samples/MvcSample/MvcUI/images/githubsharp.png 12 | Github 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /nuget/GithubSharp.Plugins.All.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GithubSharp.Plugins.All 5 | 0.0.5.1 6 | Erik Zaadi 7 | 8 | C# integration with Githubs v2 apis - Complete Plugins Module 9 | 10 | http://github.com/erikzaadi/GithubSharp 11 | https://github.com/erikzaadi/GithubSharp/raw/master/Samples/MvcSample/MvcUI/images/githubsharp.png 12 | 13 | 14 | 15 | Github 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /nuget/GithubSharp.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GithubSharp 5 | 0.0.5.1 6 | Erik Zaadi 7 | 8 | C# integration with Githubs v2 apis - Complete Module 9 | 10 | http://github.com/erikzaadi/GithubSharp 11 | https://github.com/erikzaadi/GithubSharp/raw/master/Samples/MvcSample/MvcUI/images/githubsharp.png 12 | Github 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /runtests: -------------------------------------------------------------------------------- 1 | nunit-console Tests/CoreTests/bin/Debug/GithubSharp.Tests.CoreTests.dll 2 | -------------------------------------------------------------------------------- /runtests.bat: -------------------------------------------------------------------------------- 1 | call nunit-console Tests/CoreTests/bin/Debug/GithubSharp.Tests.CoreTests.dll 2 | --------------------------------------------------------------------------------