Skip to content

Commit

Permalink
Use static service provider
Browse files Browse the repository at this point in the history
Use the static service provider in the obsolete ctor
  • Loading branch information
matthewcare committed Oct 26, 2021
1 parent 576bc1f commit cca526a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Umbraco.Core/IO/ViewHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Web.Common.DependencyInjection;
using Umbraco.Extensions;

namespace Umbraco.Cms.Core.IO
Expand All @@ -13,7 +15,11 @@ public class ViewHelper : IViewHelper
private readonly IDefaultViewContentProvider _defaultViewContentProvider;

[Obsolete("Use ctor with all params")]
public ViewHelper(IFileSystem viewFileSystem) => _viewFileSystem = viewFileSystem ?? throw new ArgumentNullException(nameof(viewFileSystem));
public ViewHelper(IFileSystem viewFileSystem)
{
_viewFileSystem = viewFileSystem ?? throw new ArgumentNullException(nameof(viewFileSystem));
_defaultViewContentProvider = StaticServiceProvider.Instance.GetRequiredService<IDefaultViewContentProvider>();
}

public ViewHelper(FileSystems fileSystems, IDefaultViewContentProvider defaultViewContentProvider)
{
Expand Down Expand Up @@ -66,7 +72,7 @@ public string CreateView(ITemplate t, bool overWrite = false)
public static string GetDefaultFileContent(string layoutPageAlias = null, string modelClassName = null,
string modelNamespace = null, string modelNamespaceAlias = null)
{
var viewContentProvider = new DefaultViewContentProvider();
var viewContentProvider = StaticServiceProvider.Instance.GetRequiredService<IDefaultViewContentProvider>();
return viewContentProvider.GetDefaultFileContent(layoutPageAlias, modelClassName, modelNamespace,
modelNamespaceAlias);
}
Expand Down

0 comments on commit cca526a

Please sign in to comment.