Making RoslynCompilationService a singleton.

* Minor code cleanup from previous compilation related PR.
This commit is contained in:
Pranav K 2014-08-11 09:49:17 -07:00
parent e96fbce95e
commit 74bb8288b0
4 changed files with 5 additions and 8 deletions

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
/// </summary>
public class RoslynCompilationService : ICompilationService
{
private static readonly ConcurrentDictionary<string, MetadataReference> _metadataFileCache =
private readonly ConcurrentDictionary<string, MetadataReference> _metadataFileCache =
new ConcurrentDictionary<string, MetadataReference>(StringComparer.OrdinalIgnoreCase);
private readonly ILibraryManager _libraryManager;
@ -154,7 +154,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
return new CompilationMessage(formatter.Format(diagnostic));
}
private bool IsError(Diagnostic diagnostic)
private static bool IsError(Diagnostic diagnostic)
{
return diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error;
}

View File

@ -35,8 +35,7 @@ namespace Microsoft.AspNet.Mvc.Razor
return _cache.GetOrAdd(file, () => CompileCore(file));
}
// TODO: Make this internal
public CompilationResult CompileCore(IFileInfo file)
internal CompilationResult CompileCore(IFileInfo file)
{
GeneratorResults results;
using (var inputStream = file.CreateReadStream())

View File

@ -39,11 +39,10 @@ namespace Microsoft.AspNet.Mvc
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.Scoped<ICompositeViewEngine, CompositeViewEngine>();
yield return describe.Singleton<IRazorCompilationService, RazorCompilationService>();
yield return describe.Singleton<IViewStartProvider, ViewStartProvider>();
yield return describe.Singleton<IRazorPageActivator, RazorPageActivator>();

View File

@ -1,7 +1,6 @@
// 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.
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.AspNet.FileSystems;