コード例 #1
0
        /// <summary>
        /// Loads and displays all cards of a given type from file / stored manual input.
        /// </summary>
        /// <param name="type"></param>
        private void LoadAndDisplay(InvestigatorCardType type)
        {
            try
            {
                IEnumerable <InvestigatorCard> cards;

                switch (type)
                {
                case InvestigatorCardType.Artifact:
                    cards = HTMLReader.GetArtifacts();
                    break;

                case InvestigatorCardType.Asset:
                    cards = HTMLReader.GetAssets();
                    break;

                case InvestigatorCardType.Spell:
                    cards = HTMLReader.GetSpells();
                    break;

                case InvestigatorCardType.Condition:
                    cards = HTMLReader.GetConditions();
                    break;

                case InvestigatorCardType.UniqueAsset:
                    cards = UniqueAssetsManual.GetAllUniqueAssets();
                    break;

                default:
                    throw new Exception("Type not handled: " + type);
                }

                MessageBox.Show(string.Format("{0} cards loaded.", cards.Count()));

                DataTable table = new DataTable("cardsTable");
                table.Columns.Add(new DataColumn("Name"));
                table.Columns.Add(new DataColumn("Traits"));
                table.Columns.Add(new DataColumn("Expansion"));

                foreach (InvestigatorCard card in cards)
                {
                    DataRow row = table.NewRow();
                    row.SetField("Name", card.Name);
                    row.SetField("Traits", string.Join(", ", card.Traits));
                    row.SetField("Expansion", card.Expansion.ToString());
                    table.Rows.Add(row);
                }

                CardDataGrid.DataSource = table;
                CardDataGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n---\n" + ex.StackTrace);
            }
        }
コード例 #2
0
        /// <summary>
        /// Loads cards from source files and manual input in memory.
        /// </summary>
        /// <returns></returns>
        public static CardCollection LoadFromSources()
        {
            CardCollection coll = new CardCollection();

            coll.InDeck.AddRange(HTMLReader.GetArtifacts());
            coll.InDeck.AddRange(HTMLReader.GetAssets());
            coll.InDeck.AddRange(HTMLReader.GetConditions());
            coll.InDeck.AddRange(HTMLReader.GetSpells());
            coll.InDeck.AddRange(UniqueAssetsManual.GetAllUniqueAssets());

            Quantifier.Quantify(coll.InDeck);

            foreach (InvestigatorCard card in coll.InDeck)
            {
                coll.Discards.Add(card, 0);
            }

            return(coll);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: jamtuba/MenuDishApp
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    HTMLReader.Initialize(services);
                    IngredientsMaker.IngredientMaker(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }
            host.Run();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            //Console.WriteLine(HTMLReader.GetWebPageHTML("http://rtai.co.uk/blog/post/3/Building-a-REST-API-in-Golang-With-a-SQL-ORM-and-JWT-Authentication"));

            /*foreach (HTMLTag tag in HTMLReader.GetHTMLTags(HTMLReader.GetWebPageHTML("http://rtai.co.uk/blog/post/3/Building-a-REST-API-in-Golang-With-a-SQL-ORM-and-JWT-Authentication")))
             * {
             *  Console.WriteLine("Start Pos: {0}\nEnd Pos: {1}\nOpening Tag: {2}\nTag Text: {3}\n\n\n\n", tag.StartPos, tag.EndPos, tag.OpeningTag, tag.TagText);
             * }*/

            /*foreach (HTMLTagPair tagPair in HTMLReader.PairHTMLTags(HTMLReader.GetHTMLTags(HTMLReader.GetWebPageHTML("http://rtai.co.uk/blog/post/3/Building-a-REST-API-in-Golang-With-a-SQL-ORM-and-JWT-Authentication"))))
             * {
             *  bool isPair = (!tagPair.isCloseOnly && !tagPair.isOpenOnly);
             *  Console.WriteLine("Open Start Pos: {0}\nOpen End Pos: {1}\nClose Start Pos: {2}\nClose End Pos: {3}\nIs Pair:{4}\n\n\n\n", tagPair.OpenStartPos, tagPair.OpenEndPos,
             *      tagPair.ClosingStartPos, tagPair.ClosingEndPos, isPair);
             * }*/

            string             htmlText = HTMLReader.GetWebPageHTML("http://rtai.co.uk/blog/post/3/Building-a-REST-API-in-Golang-With-a-SQL-ORM-and-JWT-Authentication");
            List <HTMLTagPair> TagPairs = HTMLReader.PairHTMLTags(HTMLReader.GetHTMLTags(htmlText));

            List <int> pairTagIdx      = new List <int>();
            List <int> openOnlyTagIdx  = new List <int>();
            List <int> closeOnlyTagIdx = new List <int>();

            /// <summary>
            /// Example usage:
            /// Gets the positions of open/closing pairs, followed by non-paired tags.
            /// </summary>
            foreach (HTMLTagPair _tagPair in TagPairs)
            {
                if (!_tagPair.isOpenOnly && !_tagPair.isCloseOnly)
                {
                    for (int i = _tagPair.OpenStartPos; i <= _tagPair.OpenEndPos; ++i)
                    {
                        pairTagIdx.Add(i);
                    }
                    for (int j = _tagPair.ClosingStartPos; j <= _tagPair.ClosingEndPos; ++j)
                    {
                        pairTagIdx.Add(j);
                    }
                }
                else if (_tagPair.isOpenOnly)
                {
                    for (int i = _tagPair.OpenStartPos; i <= _tagPair.OpenEndPos; ++i)
                    {
                        openOnlyTagIdx.Add(i);
                    }
                }
                else if (_tagPair.isCloseOnly)
                {
                    for (int i = _tagPair.OpenStartPos; i <= _tagPair.OpenEndPos; ++i)
                    {
                        closeOnlyTagIdx.Add(i);
                    }
                }
            }

            /// <summary>
            /// Example usage:
            /// Colours the console based upon char position existing within a paired, unpaired, or non-tagged area.
            /// </summary>
            for (int i = 0; i < htmlText.Length; ++i)
            {
                if (pairTagIdx.Contains(i))
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                else if (openOnlyTagIdx.Contains(i))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                else if (closeOnlyTagIdx.Contains(i))
                {
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.White;
                }
                Console.Write(htmlText[i]);
            }


            while (true)
            {
                ;
            }
        }
コード例 #5
0
ファイル: Http_Html_test.cs プロジェクト: labeuze/source
 public void Dispose()
 {
     if (gHTMLReader != null)
     {
         gHTMLReader.Dispose();
         gHTMLReader = null;
     }
     gXmlDocument = null;
 }
コード例 #6
0
ファイル: Http_Html_test.cs プロジェクト: labeuze/source
 public HtmlXml(TextReader tr)
 {
     gHTMLReader = new HTMLReader(tr);
 }
コード例 #7
0
ファイル: Http_Html_test.cs プロジェクト: labeuze/source
 public HtmlXml(string sUrl_Path)
 {
     gHTMLReader = new HTMLReader(sUrl_Path);
 }
コード例 #8
0
ファイル: Http_Html_test.cs プロジェクト: labeuze/source
 public HtmlXml(HTMLReader HTMLReader)
 {
     gHTMLReader = HTMLReader;
 }