public static string Parse(string template, ref Type extensions)
        {
            if (string.IsNullOrWhiteSpace(template))
            {
                return(null);
            }

            var output      = string.Empty;
            var stream      = new Stream(template);
            var shadowClass = new ShadowClass();

            shadowClass.Clear();

            while (stream.Advance())
            {
                if (ParseCodeBlock(stream, shadowClass))
                {
                    continue;
                }
                if (ParseLambda(stream, shadowClass, ref output))
                {
                    continue;
                }
                output += stream.Current;
            }

            shadowClass.Parse();
            extensions = Compiler.Compile(shadowClass);

            return(output);
        }
Esempio n. 2
0
        public static string Parse(ProjectItem projectItem, string template, List <Type> extensions)
        {
            if (string.IsNullOrWhiteSpace(template))
            {
                return(null);
            }

            var output      = string.Empty;
            var stream      = new Stream(template);
            var shadowClass = new ShadowClass();
            var contexts    = new Contexts(shadowClass);

            shadowClass.Clear();

            while (stream.Advance())
            {
                if (ParseCodeBlock(stream, shadowClass))
                {
                    continue;
                }
                if (ParseLambda(stream, shadowClass, contexts, ref output))
                {
                    continue;
                }
                output += stream.Current;
            }

            shadowClass.Parse();

            extensions.Clear();
            extensions.Add(Compiler.Compile(projectItem, shadowClass));
            extensions.AddRange(FindExtensionClasses(shadowClass));

            return(output);
        }