Exemplo n.º 1
0
        private void InitializeSyntaxHighlighter()
        {
            var stream = GetType().Assembly.GetManifestResourceStream(
                "Dynamo.UI.Resources." + Configurations.HighlightingFile);

            this.InnerTextEditor.SyntaxHighlighting = HighlightingLoader.Load(
                new XmlTextReader(stream), HighlightingManager.Instance);

            // Highlighting Digits
            var rules = this.InnerTextEditor.SyntaxHighlighting.MainRuleSet.Rules;

            rules.Add(CodeBlockUtils.CreateDigitRule());
        }
Exemplo n.º 2
0
        public void TestSyntaxHighlightRuleForDigits()
        {
            string text = "{-2468.2342E+04, dfsgdfg34534, 34534.345345, 23423, -98.7, 0..10..2, -555};";

            var rule    = CodeBlockUtils.CreateDigitRule().Regex;
            var matches = rule.Matches(text);

            // Expected results (8):
            // -2468.2342E+04
            // 34534.345345
            // 23423
            // -98.7
            // 0
            // 10
            // 2
            // -555
            Assert.AreEqual(8, matches.Count);
            var actual = matches.Cast <Match>().Select(m => m.Value).ToArray();

            string[] expected = new string[] { "-2468.2342E+04", "34534.345345", "23423", "-98.7", "0", "10", "2", "-555" };
            Assert.IsTrue(expected.SequenceEqual(actual));
        }