Making RoslynCompilationService a singleton.
* Minor code cleanup from previous compilation related PR.
This commit is contained in:
parent
e96fbce95e
commit
74bb8288b0
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RoslynCompilationService : ICompilationService
|
public class RoslynCompilationService : ICompilationService
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<string, MetadataReference> _metadataFileCache =
|
private readonly ConcurrentDictionary<string, MetadataReference> _metadataFileCache =
|
||||||
new ConcurrentDictionary<string, MetadataReference>(StringComparer.OrdinalIgnoreCase);
|
new ConcurrentDictionary<string, MetadataReference>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
@ -154,7 +154,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
|
||||||
return new CompilationMessage(formatter.Format(diagnostic));
|
return new CompilationMessage(formatter.Format(diagnostic));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsError(Diagnostic diagnostic)
|
private static bool IsError(Diagnostic diagnostic)
|
||||||
{
|
{
|
||||||
return diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error;
|
return diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
return _cache.GetOrAdd(file, () => CompileCore(file));
|
return _cache.GetOrAdd(file, () => CompileCore(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make this internal
|
internal CompilationResult CompileCore(IFileInfo file)
|
||||||
public CompilationResult CompileCore(IFileInfo file)
|
|
||||||
{
|
{
|
||||||
GeneratorResults results;
|
GeneratorResults results;
|
||||||
using (var inputStream = file.CreateReadStream())
|
using (var inputStream = file.CreateReadStream())
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,10 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
yield return describe.Instance<IMvcRazorHost>(new MvcRazorHost(typeof(RazorPage).FullName));
|
yield return describe.Instance<IMvcRazorHost>(new MvcRazorHost(typeof(RazorPage).FullName));
|
||||||
|
|
||||||
yield return describe.Transient<ICompilationService, RoslynCompilationService>();
|
yield return describe.Singleton<ICompilationService, RoslynCompilationService>();
|
||||||
|
yield return describe.Singleton<IRazorCompilationService, RazorCompilationService>();
|
||||||
yield return describe.Singleton<IViewEngineProvider, DefaultViewEngineProvider>();
|
yield return describe.Singleton<IViewEngineProvider, DefaultViewEngineProvider>();
|
||||||
yield return describe.Scoped<ICompositeViewEngine, CompositeViewEngine>();
|
yield return describe.Scoped<ICompositeViewEngine, CompositeViewEngine>();
|
||||||
yield return describe.Singleton<IRazorCompilationService, RazorCompilationService>();
|
|
||||||
yield return describe.Singleton<IViewStartProvider, ViewStartProvider>();
|
yield return describe.Singleton<IViewStartProvider, ViewStartProvider>();
|
||||||
|
|
||||||
yield return describe.Singleton<IRazorPageActivator, RazorPageActivator>();
|
yield return describe.Singleton<IRazorPageActivator, RazorPageActivator>();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNet.FileSystems;
|
using Microsoft.AspNet.FileSystems;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue