Exemple #1
0
        static void Main(string[] args)
        {
            // Read in JSON string
            var json = new System.Net.WebClient().DownloadString("http://files.olo.com/pizzas.json");

            // Create a list of pizzas from JSON string.
            //      - Convert JSON string to lower.
            //      - Toppings property is a SortedSet so that we can use the LINQ GroupBy.
            List <pizza> pizzas = JsonConvert.DeserializeObject <List <pizza> >(json.ToLower());

            // Use LINQ to group, order, and select the top 20 pizzas
            var results = pizzas.GroupBy(x => string.Join("", x.toppings))
                          .OrderByDescending(x => x.Count())
                          .Take(20);

            // Print results
            int ctr = 1;

            foreach (var p in results)
            {
                Console.WriteLine(string.Format("Rank=> {0}  Orders=> {1}  Toppings=> {2}", ctr.ToString().PadLeft(2, ' '), p.Count().ToString().PadLeft(5, ' '), string.Join(", ", p.First().toppings)));
                ctr++;
            }

            Console.ReadKey();
        }
Exemple #2
0
 public static void printUpdateInfo()
 {
     try
     {
         ProgramLog.Log("Attempting to retreive Build Info...");
         string buildInfo = new System.Net.WebClient().DownloadString(UpdateInfo).Trim();
         string toString  = "comments: ";
         if (buildInfo.ToLower().Contains(toString))
         {
             buildInfo = buildInfo.Remove(0, buildInfo.ToLower().IndexOf(toString.ToLower()) + toString.Length).Trim().Replace("<br/>", "\n"); //This is also used for the forums, so easy use here ;D
             if (buildInfo.Length > 0)
             {
                 ProgramLog.Log("Build Comments: " + buildInfo);
             }
         }
     }
     catch (Exception)
     {
     }
 }
        public static void printUpdateInfo()
        {
            try
            {
                Program.tConsole.WriteLine("Attempting to retreive Build Info...");
                String buildInfo = new System.Net.WebClient().DownloadString(UpdateInfo).Trim();
                String toString = "comments: ";
                if (buildInfo.ToLower().Contains(toString))
                {
                    buildInfo = buildInfo.Remove(0, buildInfo.ToLower().IndexOf(toString.ToLower()) + toString.Length).Trim().Replace("<br/>", "\n"); //This is also used for the forums, so easy use here ;D
                    if (buildInfo.Length > 0)
                    {
                        Program.tConsole.WriteLine("Build Comments: " + buildInfo);
                    }
                }
            }
            catch (Exception)
            {

            }
        }