示例#1
0
        private void InitializeSyntaxHighlighter()
        {
            var stream = GetType().Assembly.GetManifestResourceStream(
                "Dynamo.Wpf.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(CodeBlockEditorUtils.CreateDigitRule());
            rules.Add(CreateClassHighlightRule());
            rules.Add(CreateMethodHighlightRule());
        }
示例#2
0
        public void TestSyntaxHighlightRuleForDigits()
        {
            string text = "{-2468.2342E+04, dfsgdfg34534, 34534.345345, 23423, -98.7, 0..10..2, -555};";

            var rule    = CodeBlockEditorUtils.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));
        }