Beispiel #1
0
        // Display the GitHub data contained in githubClient
        static void displayGithubData(GitHubClient githubClient)
        {
            // GitHub name is sometimes empty
            if (githubClient.name != null)
            {
                Console.WriteLine("GitHub user = {0}, name = {1}",
                githubClient.login, githubClient.name);
            }
            else
            {
                Console.WriteLine("GitHub user = {0}",
                githubClient.login);
            }

            Console.WriteLine("Followed by {0} users, and following {1} users",
                                githubClient.followers, githubClient.following);
            Console.WriteLine("Number of repositories: {0}", githubClient.public_repos);
            //Console.WriteLine("Repo URL: {0}", githubClient.repos_url);

            if (githubClient.public_repos > 0)
            {
                displayGithubRepos(githubClient.repos_url);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Display Github data for user until <enter> is pressed
            while (true)
            {
                Console.Write("Enter the GitHub username (Press <enter> to exit): ");
                string gitUser = Console.ReadLine();
                if (gitUser.Length == 0)
                {
                    break;
                }

                // Get the GitHub data
                GitHubClient githubClient = new GitHubClient();
                if (getGithubData(gitUser, ref githubClient))
                {
                    //Display the Github data
                    displayGithubData(githubClient);
                }
            }
        }
Beispiel #3
0
 // Read GitHub data for input userName, placing it in githubClient
 // Return true if data was successfully read, otherwise return false
 static bool getGithubData(string userName, ref GitHubClient githubClient)
 {
     try
     {
         string json = getWebData("https://api.github.com/users/" + userName,
                                          "User " + userName + " not found");
         if (json.Length > 0)
         {
             githubClient =
                        JsonConvert.DeserializeObject<GitHubClient>(json);
             return true;
         }
         else
         {
             return false;
         }
     }
     catch (Exception e)
     {
         Console.WriteLine
             ("An error occurred: {0}", e.Message);
         return false;
     }
 }