コード例 #1
0
ファイル: TemplatingEngine.cs プロジェクト: atifaziz/t4
        public string PreprocessTemplate(string content, ITextTemplatingEngineHost host, string className,
                                         string classNamespace, out string language, out string [] references)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }
            if (className == null)
            {
                throw new ArgumentNullException(nameof(className));
            }
            language   = null;
            references = null;

            var pt = ParsedTemplate.FromTextInternal(content, host);

            if (pt.Errors.HasErrors)
            {
                host.LogErrors(pt.Errors);
                return(null);
            }
            return(PreprocessTemplateInternal(pt, content, host, className, classNamespace, out language, out references));
        }
コード例 #2
0
ファイル: TemplatingEngine.cs プロジェクト: atifaziz/t4
        public async Task <CompiledTemplate> CompileTemplateAsync(string content, ITextTemplatingEngineHost host, CancellationToken token)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            var pt = ParsedTemplate.FromTextInternal(content, host);

            if (pt.Errors.HasErrors)
            {
                host.LogErrors(pt.Errors);
                return(null);
            }

            var tpl = await CompileTemplateInternal(pt, content, host, null, token).ConfigureAwait(false);

            return(tpl?.template);
        }