Exemplo n.º 1
0
        public static void ScrapeRow(IFrameworkURLData data, HtmlNode row, RowType type)
        {
            var cell = row.SelectSingleNode("./td");
            var name = cell.RealInnerText().Trim();

            string link;

            try
            {
                link = cell.SelectSingleNode("./p/code/a").GetAttributeValue("href", "");
            }
            catch
            {
                using (var writer = new StreamWriter(@"Output\Missing.txt", true))
                {
                    writer.WriteLine(name);
                }
                Console.WriteLine("No link for " + name);
                return;
            }

            foreach (var replace in data.LinkReplaces)
            {
                link = link.Replace(replace.Key, replace.Value);
            }

            var outputPath = @"Output\";

            if (type == RowType.Interface)
            {
                outputPath += @"Protocols\" + (name.ToLower().Contains("delegate") ? @"Delegates\" : "");
            }

            Directory.CreateDirectory(outputPath);

            using (var writer = new StreamWriter(outputPath + name + ".cs"))
            {
                try
                {
                    writer.Write(Indenter.IndentDocument(
                                     Finals.Class(link, data.Namespace,
                                                  type == RowType.Interface, data.Usings)));
                }
                catch
                {
                    using (var wr = new StreamWriter(@"Output\Missing.txt", true))
                    {
                        wr.WriteLine(name);
                    }
                    Console.WriteLine("404 for " + name);
                    return;
                }

                writer.Flush();
            }
        }
Exemplo n.º 2
0
 /// <summary> Sub function to choose which array to start
 /// updating depending on starting bracket
 /// </summary>
 public void updateWinners(TourneyMatchUp updated)
 {
     if (Finals.State == MatchState.VictorFound)
     {
         //update finals and winner
         TourneyWinner.Team = Finals.Winner;
         TourneyWinner.Update();
         //////
         ///TODO FINISH GAME
         //////
     }
     else
     {
         if (Semis.Contains <TourneyMatchUp>(updated))
         {
             // update semis and finals
             Team team1 = null, team2 = null;
             if (Semis[0].State == MatchState.VictorFound || Semis[0].State == MatchState.ByeRound)
             {
                 team1 = Semis[0].Winner;
             }
             if (Semis[1].State == MatchState.VictorFound || Semis[1].State == MatchState.ByeRound)
             {
                 team2 = Semis[1].Winner;
             }
             Finals.reset(team1, team2);
         }
         else if (Quarters.Contains <TourneyMatchUp>(updated))
         {
             int curRowCounter = 0, nextRowCounter = 0;
             for (int i = 0; i < Quarters.Length; i++)
             {
                 Team first  = (Quarters[curRowCounter].State == MatchState.VictorFound) ? Quarters[curRowCounter].Winner : null;
                 Team second = (Quarters[curRowCounter + 1].State == MatchState.VictorFound) ? Quarters[curRowCounter + 1].Winner : null;
                 Semis[nextRowCounter].reset(first, second);
                 curRowCounter += 2;
                 nextRowCounter++;
             }
             // update quarters and semis
         }
         else
         {
             int curRowCounter = 0, nextRowCounter = 0;
             for (int i = 0; i < Starters.Length; i++)
             {
                 Team first  = (Starters[curRowCounter].State == MatchState.VictorFound) ? Starters[curRowCounter].Winner : null;
                 Team second = (Starters[curRowCounter + 1].State == MatchState.VictorFound) ? Starters[curRowCounter + 1].Winner : null;
                 Quarters[nextRowCounter].reset(first, second);
                 curRowCounter += 2;
                 nextRowCounter++;
             }
             //update starters and quarters
         }
     }
 }
Exemplo n.º 3
0
        public static void ScrapeFramework(IFrameworkURLData data)
        {
            if (Directory.Exists(@"Output\"))
            {
                Directory.Delete(@"Output\", true);
            }
            Directory.CreateDirectory(@"Output\");
            Directory.CreateDirectory(@"Output\Additions");
            Directory.CreateDirectory(@"Output\Protocols");

            using (var client = new HttpClient())
            {
                var resp = client.GetStringAsync(data.URL).Result;
                var doc  = new HtmlDocument {
                    OptionFixNestedTags = true
                };
                doc.LoadHtml(resp);

                var tables = doc.DocumentNode.SelectNodes("//table[@class='collection-table Objective-C']");

                var classRows = tables[0].SelectNodes("./tbody/tr");
                foreach (var classRow in classRows)
                {
                    ScrapeRow(data, classRow, RowType.Class);
                }

                var interfaceRows = tables[1].SelectNodes("./tbody/tr");
                foreach (var interfaceRow in interfaceRows)
                {
                    ScrapeRow(data, interfaceRow, RowType.Interface);
                }

                foreach (var extra in data.Extra)
                {
                    using (var writer = new StreamWriter("Output\\" + extra.Key + ".cs"))
                    {
                        try
                        {
                            writer.Write(Indenter.IndentDocument(
                                             Finals.Class(extra.Value, data.Namespace,
                                                          false, data.Usings)));
                        }
                        catch
                        {
                        }

                        writer.Flush();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void RefreshFinals(object sender, EventArgs e)
        {
            labelTeamsToSendUp.Text = "Teams to send up from each game: " + (numericTeamsPerGame.Value - numericTeamsToCut.Value).ToString();

            var report = Finals.Ascension(Holder.Fixture, (int)numericTeamsPerGame.Value, (int)numericTeamsToCut.Value, (int)numericTracks.Value, (int)numericFreeRides.Value);

            using (StringWriter sw = new StringWriter())
            {
                sw.Write(report.ToSvg(true));
                document = SvgDocument.FromSvg<SvgDocument>(sw.ToString());
                aspectRatio = document.ViewBox.Width / document.ViewBox.Height;
                TimerRedrawTick(null, null);
            }
        }
Exemplo n.º 5
0
        public string GetTrivia()
        {
            var NewLine = Finals.NewLine;
            var output  = "/// <summary>" + NewLine + "/// " +
                          Finals.ParseAsDescription(Description) + NewLine +
                          "/// </summary>" + NewLine;

            if (iOSVersion.HasValue)
            {
                output += "[iOSVersion(" + iOSVersion + ")]" + NewLine;
            }
            if (Deprecated)
            {
                output += "[Obsolete]" + NewLine;
            }
            if (CSharpName != RawName)
            {
                output += "[Export(\"" + RawName + "\")]" + NewLine;
            }
            return(output);
        }