Пример #1
0
        public override Inline ToInline(CodeLexem codeLexem)
        {
            switch (codeLexem.Type)
            {
            case LexemType.Symbol:
            case LexemType.Object:
                return(CreateRun(codeLexem.Text, Colors.LightGray));

            case LexemType.Property:
                return(CreateRun(codeLexem.Text, Colors.Blue));

            case LexemType.Value:
            case LexemType.Space:
            case LexemType.PlainText:
            case LexemType.String:
                return(CreateRun(codeLexem.Text, Colors.Black));

            case LexemType.LineBreak:
                return(new LineBreak());

            case LexemType.Complex:
            case LexemType.Quotes:
                return(CreateRun(codeLexem.Text, Colors.Brown));
            }

            throw new NotImplementedException(string.Format("Lexem type {0} has no specific colors.", codeLexem.Type));
        }
Пример #2
0
        public override Inline ToInline(CodeLexem codeLexem)
        {
            switch (codeLexem.Type)
            {
                case LexemType.Error:
                    return CreateRun(codeLexem.Text, Colors.LightGray);
                case LexemType.Symbol:
                    return CreateRun(codeLexem.Text, Colors.Blue);
                case LexemType.Object:
                    return CreateRun(codeLexem.Text, Colors.Brown);
                case LexemType.Property:
                    return CreateRun(codeLexem.Text, Colors.Red);
                case LexemType.Value:
                    return CreateRun(codeLexem.Text, Colors.Blue);
                case LexemType.Space:
                    return CreateRun(codeLexem.Text, Colors.Black);
                case LexemType.LineBreak:
                    return new LineBreak();
                case LexemType.Complex:
                    return CreateRun(codeLexem.Text, Colors.LightGray);
                case LexemType.Comment:
                    return CreateRun(codeLexem.Text, Colors.Green);
                case LexemType.PlainText:
                    return CreateRun(codeLexem.Text, Colors.Black);
                case LexemType.String:
                    return CreateRun(codeLexem.Text, Colors.Brown);
                case LexemType.KeyWord:
                    return CreateRun(codeLexem.Text, Colors.Blue);
                case LexemType.Quotes:
                    return CreateRun(codeLexem.Text, Colors.Blue);
            }

            throw new NotImplementedException(string.Format("Lexem type {0} has no specific colors.", codeLexem.Type));
        }
 public void FillInlines(string text, InlineCollection collection)
 {
     text = text.Replace("\r", "");
     var codeLexem = new CodeLexem(text);
     var list = codeLexem.Parse(CodeLanguage);
     foreach (CodeLexem current in list)
     {
         collection.Add(current.ToInline(CodeLanguage));
     }
 }
Пример #4
0
        public void FillInlines(string text, InlineCollection collection)
        {
            text = text.Replace("\r", "");
            var codeLexem = new CodeLexem(text);
            var list      = codeLexem.Parse(CodeLanguage);

            foreach (CodeLexem current in list)
            {
                collection.Add(current.ToInline(CodeLanguage));
            }
        }
Пример #5
0
        public void should_parse_properties_objects_and_symbols()
        {
            const string TestMessage = "[{\"$type\":\"NSB.Messages.CRM.RegisterCustomer, NSB.Messages\",\"Name\":\"Hadi\",\"Password\":\"123456\",\"EmailAddress\":\"[email protected]\",\"RegistrationDate\":\"2013-01-28T03:24:05.0546437Z\"}]";

            var lexemes = new CodeLexem(TestMessage).Parse(CodeLanguage.Json);

            lexemes.Count(lx => lx.Type == LexemType.Property).ShouldBe(5);
            lexemes.Count(lx => lx.Type == LexemType.Value).ShouldBe(5);
            lexemes.Count(lx => lx.Type == LexemType.Quotes).ShouldBe(20);
            lexemes.Count(lx => lx.Type == LexemType.Symbol).ShouldBe(13);
        }
Пример #6
0
        public void should_parse_complex_json_graphs()
        {
            const string JsonGraph = @"{""menu"": {
              ""id"": ""file"",
              ""value"": ""File"",
              ""popup"": {
            ""menuitem"": [
              {""value"": ""New"", ""onclick"": ""CreateNewDoc()""},
              {""value"": ""Open"", ""onclick"": ""OpenDoc()""},
              {""value"": ""Close"", ""onclick"": ""CloseDoc()""}
            ]
              }
            }}";

            var lexemes = new CodeLexem(JsonGraph).Parse(CodeLanguage.Json);

            lexemes.Count(lx => lx.Type == LexemType.Property).ShouldBe(11);
            lexemes.Count(lx => lx.Type == LexemType.Value).ShouldBe(8);
            lexemes.Count(lx => lx.Type == LexemType.LineBreak).ShouldBe(11);
        }
Пример #7
0
 public virtual Inline ToInline(CodeLexem codeLexem)
 {
     return new Run(codeLexem.Text);
 }
Пример #8
0
 public virtual Inline ToInline(CodeLexem codeLexem)
 {
     return(new Run(codeLexem.Text));
 }