Exemple #1
0
        public void ExceptionIfRulesVersionIsIncompatible()
        {
            TypesRegistry typesRegistry = new TypesRegistry();

            string rulesText = @"== Rendering Rules ==

=== Options ===
{| class='wikitable' border='1' cellspacing='0' cellpadding='2' 
|- style='background-color:#F8F4C2'
! Option
! Value
! Comment 
|-
| RulesVersion || 1.7 || Minimal version of [[GroundTruth]] needed to use these rules
|-
| LandBackgroundColor || #218CFF || Color of the map background. If not set, the default unit color will be used
|-
|}
";

            using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(rulesText)))
            {
                WikiRulesParser parser = new WikiRulesParser(
                    stream,
                    typesRegistry,
                    null,
                    SerializersRegistry);
                parser.Parse();
                RenderingRuleSet rules = parser.Rules;
            }
        }
Exemple #2
0
        public void ParseCharConversionTable()
        {
            CharactersConversionDictionary charactersConversionDictionary = new CharactersConversionDictionary();

            using (Stream stream = File.OpenRead(@"..\..\..\GroundTruth\Rules\CharacterConversionTable.txt"))
            {
                WikiRulesParser parser = new WikiRulesParser(
                    stream,
                    null,
                    charactersConversionDictionary,
                    SerializersRegistry);
                parser.Parse();
            }

            // check character conversion
            Assert.AreEqual("Cevapcici", charactersConversionDictionary.Convert("Čevapčići"));
        }
Exemple #3
0
        private TypesRegistry ParseRules(string rulesFile, out RenderingRuleSet rules)
        {
            TypesRegistry typesRegistry = new TypesRegistry();

            using (Stream stream = File.OpenRead(rulesFile))
            {
                WikiRulesParser parser = new WikiRulesParser(
                    stream,
                    typesRegistry,
                    null,
                    SerializersRegistry);
                parser.Parse();
                rules = parser.Rules;
            }

            return(typesRegistry);
        }
        private void FetchRulesFromWikiPage(
            ITaskRunner taskRunner,
            string wikiPageSource,
            string whatIsBeingFetched)
        {
            consoleLogger.WriteLine(log, Level.Info,
                                    "Fetching {1} from '{0}'...",
                                    wikiPageSource,
                                    whatIsBeingFetched);

            using (Stream stream = WikiPageStreamProvider.Open(wikiPageSource))
            {
                using (WikiRulesParser rulesParser = new WikiRulesParser(
                           stream,
                           taskRunner.MapMakerSettings.TypesRegistry,
                           taskRunner.MapMakerSettings.CharactersConversionDictionary,
                           serializersRegistry))
                {
                    rulesParser.Parse();
                }
            }
        }
Exemple #5
0
        private void LoadRulesIfNecessary()
        {
            if (Settings.RenderingRules == null)
            {
                consoleLogger.WriteLine(log, Level.Info,
                                        "Fetching rendering rules from '{0}'...",
                                        Settings.RenderingRulesSource);

                using (Stream stream = WikiPageStreamProvider.Open(Settings.RenderingRulesSource))
                {
                    using (WikiRulesParser parser = new WikiRulesParser(
                               stream,
                               Settings.TypesRegistry,
                               Settings.CharactersConversionDictionary,
                               serializersRegistry))
                    {
                        parser.Parse();
                        Settings.RenderingRules = parser.Rules;
                    }
                }
            }
        }