Example #1
0
        public void AddLambda(string code, string type, string name, int startIndex)
        {
            if (classAdded == false)
            {
                snippets.Add(Snippet.Create(SnippetType.Class, classTemplate));
                offset    += classTemplate.Length;
                classAdded = true;
            }

            var method = $"bool __{startIndex} ({type} {name}) {{ return ";
            var index  = code.IndexOf("=>", StringComparison.Ordinal) + 2;

            code = code.Remove(0, index);

            snippets.Add(Snippet.Create(SnippetType.Class, method));
            offset += method.Length;

            snippets.Add(Snippet.Create(SnippetType.Lambda, code, offset, startIndex, startIndex + code.Length, index));
            offset += code.Length;

            snippets.Add(Snippet.Create(SnippetType.Class, ";}"));
            offset += 2;
        }
Example #2
0
 public void AddUsing(string code, int startIndex)
 {
     snippets.Add(Snippet.Create(SnippetType.Using, code, offset, startIndex, startIndex + code.Length));
     offset += code.Length;
 }