예제 #1
0
        public RazorTemplateCompiler(
            RazorSourceGenerator sourceGenerator,
            RoslynCompilationService roslynCompilationService,
            RazorLightProject razorLightProject,
            RazorLightOptions razorLightOptions)
        {
            _razorSourceGenerator = sourceGenerator ?? throw new ArgumentNullException(nameof(sourceGenerator));
            _compiler             = roslynCompilationService ?? throw new ArgumentNullException(nameof(roslynCompilationService));
            _razorProject         = razorLightProject ?? throw new ArgumentNullException(nameof(razorLightProject));
            _razorLightOptions    = razorLightOptions ?? throw new ArgumentNullException(nameof(razorLightOptions));

            // This is our L0 cache, and is a durable store. Views migrate into the cache as they are requested
            // from either the set of known precompiled views, or by being compiled.
            var cacheOptions = Options.Create(new MemoryCacheOptions());

            _cache = new MemoryCache(cacheOptions);

            _normalizedKeysCache = new ConcurrentDictionary <string, string>(StringComparer.Ordinal);

            // We need to validate that the all of the precompiled views are unique by path (case-insensitive).
            // We do this because there's no good way to canonicalize paths on windows, and it will create
            // problems when deploying to linux. Rather than deal with these issues, we just don't support
            // views that differ only by case.
            _precompiledViews = new Dictionary <string, CompiledTemplateDescriptor>(
                5,                 //Change capacity when precompiled views are arrived
                StringComparer.OrdinalIgnoreCase);
        }
예제 #2
0
 public TemplateFactoryProvider(
     RazorSourceGenerator generator,
     RoslynCompilationService compiler,
     RazorLightOptions razorOptions)
 {
     sourceGenerator  = generator ?? throw new ArgumentNullException(nameof(generator));
     templateCompiler = compiler ?? throw new ArgumentNullException(nameof(compiler));
     options          = razorOptions ?? throw new ArgumentNullException(nameof(razorOptions));
 }