示例#1
0
        public static GitHubClient GetGitHubClient(PluginParams settings)
        {
            var github = new GitHubClient(new ProductHeaderValue(settings.GitHubProductName));

            github.Connection.Credentials = new Credentials(settings.GithubCredentialToken);
            return(github);
        }
示例#2
0
        public static PluginParams GetAFSettings(AFElement orgElement)
        {
            try
            {
                //getting repository settings from the element:
                var gitHubOwner           = AFSDKHelpers.GetAttributeValue <string>(orgElement, "Owner");
                var gitHubCredentialToken = AFSDKHelpers.GetAttributeValue <string>(orgElement, "GitHubCredentialToken");
                var gitHubProductName     = AFSDKHelpers.GetAttributeValue <string>(orgElement, "GitHubProductName");

                var settings = new PluginParams()
                {
                    GitHubOwner           = gitHubOwner,
                    GitHubProductName     = gitHubProductName,
                    GithubCredentialToken = gitHubCredentialToken,
                    RepositoryTemplate    = orgElement.Database.ElementTemplates["Repository"]
                };

                ValidateParameters(settings);
                return(settings);
            }
            catch (Exception e)
            {
                throw new CouldNotInitializeSettingsFromAFException(e);
            }
        }
示例#3
0
 public static void ValidateParameters(PluginParams pluginParams)
 {
     if (string.IsNullOrEmpty(pluginParams.GithubCredentialToken) || string.IsNullOrEmpty(pluginParams.GitHubProductName))
     {
         throw new GitHubDataCollectorHasInvalidConfiguration();
     }
 }
示例#4
0
        public static List <AFElement> FindRepositoryById(AFElement orgElement, PluginParams pluginParams, string repositoryId)
        {
            AFSearchToken   templateToken = new AFSearchToken(AFSearchFilter.Template, AFSearchOperator.Equal, pluginParams.RepositoryTemplate.GetPath());
            AFSearchToken   valueToken    = new AFSearchToken(AFSearchFilter.Value, AFSearchOperator.Equal, repositoryId, pluginParams.RepositoryTemplate.AttributeTemplates[RepositoryIdAttributeName].GetPath());
            AFElementSearch elementSearch = new AFElementSearch(orgElement.Database, "FindRepositoryById", new[] { templateToken, valueToken });

            elementSearch.Refresh();
            var searchResult = elementSearch.FindElements(0, true, 1).ToList();

            return(searchResult);
        }