Пример #1
0
        /// <summary>
        /// Returns strong typed template created from specified source.
        /// </summary>
        public static ITemplate <TModel> Compile <TModel>(string source)
        {
            if (string.IsNullOrEmpty(source))
            {
                throw new ArgumentException(
                          "Template source can't be null or empty string.",
                          "source");
            }

            var compilationResult = TemplateCompiler.Compile(
                typeof(TemplateBase <TModel>),
                source,
                Enumerable.Empty <string>() /* namespaces */,
                null /* compilation directory */);

            return(new Template <TemplateBase <TModel>, TModel>(compilationResult.Type, compilationResult.SourceCode, null));
        }