Example #1
0
        protected async Task <RepositoryOrigin> GetRepositoryOrigin(UriString uri)
        {
            if (uri == null)
            {
                return(RepositoryOrigin.Other);
            }

            Debug.Assert(apiFactory != null, "apiFactory cannot be null. Did you call the right constructor?");
            SimpleApiClient = await apiFactory.Create(uri);

            var isdotcom = HostAddress.IsGitHubDotComUri(uri.ToRepositoryUrl());

            if (isdotcom)
            {
                return(RepositoryOrigin.DotCom);
            }
            else
            {
                var repo = await SimpleApiClient.GetRepository();

                if ((repo.FullName == ActiveRepoName || repo.Id == 0) && await SimpleApiClient.IsEnterprise())
                {
                    return(RepositoryOrigin.Enterprise);
                }
            }

            return(RepositoryOrigin.Other);
        }
 public void ClearFromCache(ISimpleApiClient client)
 {
     lock (cache)
     {
         if (cache.ContainsKey(client.OriginalUrl))
             cache.Remove(client.OriginalUrl);
     }
 }
 public void ClearFromCache(ISimpleApiClient client)
 {
     lock (cache)
     {
         if (cache.ContainsKey(client.OriginalUrl))
         {
             cache.Remove(client.OriginalUrl);
         }
     }
 }
Example #4
0
        static async Task <bool> IsValidRepository(ISimpleApiClient client)
        {
            try
            {
                var repo = await client.GetRepository();

                return(repo.Id != 0);
            }
            catch
            {
                return(false);
            }
        }
        protected async Task<bool> IsAGitHubRepo()
        {
            var uri = ActiveRepoUri;
            if (uri == null)
                return false;

            SimpleApiClient = apiFactory.Create(uri);

            if (!HostAddress.IsGitHubDotComUri(uri.ToRepositoryUrl()))
            {
                var repo = await SimpleApiClient.GetRepository();
                return repo.FullName == ActiveRepoName && SimpleApiClient.IsEnterprise();
            }
            return true;
        }
        protected async Task <bool> IsAGitHubRepo()
        {
            var uri = ActiveRepoUri;

            if (uri == null)
            {
                return(false);
            }

            SimpleApiClient = apiFactory.Create(uri);

            if (!HostAddress.IsGitHubDotComUri(uri.ToRepositoryUrl()))
            {
                var repo = await SimpleApiClient.GetRepository();

                return(repo.FullName == ActiveRepoName && SimpleApiClient.IsEnterprise());
            }
            return(true);
        }
Example #7
0
        protected async Task <bool> IsUserAuthenticated()
        {
            if (SimpleApiClient == null)
            {
                if (ActiveRepo == null)
                {
                    return(false);
                }

                var uri = ActiveRepoUri;
                if (uri == null)
                {
                    return(false);
                }

                SimpleApiClient = await apiFactory.Create(uri);
            }

            return(SimpleApiClient?.IsAuthenticated() ?? false);
        }
        protected async Task <bool> IsAGitHubRepo()
        {
            var uri = ActiveRepoUri;

            if (uri == null)
            {
                return(false);
            }

            Debug.Assert(apiFactory != null, "apiFactory cannot be null. Did you call the right constructor?");
            SimpleApiClient = apiFactory.Create(uri);

            var isdotcom = HostAddress.IsGitHubDotComUri(uri.ToRepositoryUrl());

            if (!isdotcom)
            {
                var repo = await SimpleApiClient.GetRepository();

                return((repo.FullName == ActiveRepoName || repo.Id == 0) && SimpleApiClient.IsEnterprise());
            }
            return(isdotcom);
        }
Example #9
0
        protected async Task <bool> IsGitHubRepo()
        {
            RefreshRepo();

            var uri = ActiveRepo?.CloneUrl;

            if (uri == null)
            {
                return(false);
            }

            SimpleApiClient = await ApiFactory.Create(uri);

            var isdotcom = HostAddress.IsGitHubDotComUri(uri.ToRepositoryUrl());

            if (!isdotcom)
            {
                var repo = await SimpleApiClient.GetRepository();

                return((repo.FullName == ActiveRepo.Name || repo.Id == 0) && SimpleApiClient.IsEnterprise());
            }
            return(isdotcom);
        }
 public void ClearFromCache(ISimpleApiClient client)
 {
     ISimpleApiClient c;
     cache.TryRemove(client.OriginalUrl, out c);
 }
Example #11
0
        public void ClearFromCache(ISimpleApiClient client)
        {
            ISimpleApiClient c;

            cache.TryRemove(client.OriginalUrl, out c);
        }
        protected bool IsUserAuthenticated()
        {
            if (SimpleApiClient == null)
            {
                if (ActiveRepo == null)
                    return false;

                var uri = ActiveRepoUri;
                if (uri == null)
                    return false;

                SimpleApiClient = apiFactory.Create(uri);
            }

            return SimpleApiClient?.IsAuthenticated() ?? false;
        }
        protected async Task<RepositoryOrigin> GetRepositoryOrigin()
        {
            if (ActiveRepo == null)
                return RepositoryOrigin.NonGitRepository;

            var uri = ActiveRepoUri;
            if (uri == null)
                return RepositoryOrigin.Other;

            Debug.Assert(apiFactory != null, "apiFactory cannot be null. Did you call the right constructor?");
            SimpleApiClient = apiFactory.Create(uri);

            var isdotcom = HostAddress.IsGitHubDotComUri(uri.ToRepositoryUrl());

            if (isdotcom)
            {
                return RepositoryOrigin.DotCom;
            }
            else
            {
                var repo = await SimpleApiClient.GetRepository();

                if ((repo.FullName == ActiveRepoName || repo.Id == 0) && SimpleApiClient.IsEnterprise())
                {
                    return RepositoryOrigin.Enterprise;
                }
            }

            return RepositoryOrigin.Other;
        }
Example #14
0
        protected async Task<bool> IsGitHubRepo()
        {
            RefreshRepo();

            var uri = ActiveRepo?.CloneUrl;
            if (uri == null)
                return false;

            SimpleApiClient = ApiFactory.Create(uri);

            var isdotcom = HostAddress.IsGitHubDotComUri(uri.ToRepositoryUrl());
            if (!isdotcom)
            {
                var repo = await SimpleApiClient.GetRepository();
                return (repo.FullName == ActiveRepo.Name || repo.Id == 0) && SimpleApiClient.IsEnterprise();
            }
            return isdotcom;
        }