From 8bc077fa1871cb050caa390dfee22890d8b8048c Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Wed, 4 Mar 2020 13:37:05 +0100 Subject: [PATCH] Introduce methods on current, that can be necessary if not using the obsolete properties. --- src/Umbraco.Web/Composing/Current.cs | 6 ++++++ src/Umbraco.Web/Models/RegisterModel.cs | 3 +-- src/Umbraco.Web/UmbracoHelper.cs | 10 +++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web/Composing/Current.cs b/src/Umbraco.Web/Composing/Current.cs index ec65046e84..2419eaa6d4 100644 --- a/src/Umbraco.Web/Composing/Current.cs +++ b/src/Umbraco.Web/Composing/Current.cs @@ -88,6 +88,12 @@ namespace Umbraco.Web.Composing public static UmbracoHelper UmbracoHelper => Factory.GetInstance(); + public static IUmbracoComponentRenderer UmbracoComponentRenderer + => Factory.GetInstance(); + public static ITagQuery TagQuery + => Factory.GetInstance(); + public static IPublishedContentQuery PublishedContentQuery + => Factory.GetInstance(); public static DistributedCache DistributedCache => Factory.GetInstance(); diff --git a/src/Umbraco.Web/Models/RegisterModel.cs b/src/Umbraco.Web/Models/RegisterModel.cs index 86a5459a74..fd6cadc04e 100644 --- a/src/Umbraco.Web/Models/RegisterModel.cs +++ b/src/Umbraco.Web/Models/RegisterModel.cs @@ -5,7 +5,6 @@ using System.ComponentModel.DataAnnotations; using System.Web; using System.Web.Mvc; using Umbraco.Core; -using Umbraco.Core.Composing; using Umbraco.Web.Security; using Current = Umbraco.Web.Composing.Current; @@ -65,7 +64,7 @@ namespace Umbraco.Web.Models /// [Required] public string Password { get; set; } - + /// /// The username of the model, if UsernameIsEmail is true then this is ignored. /// diff --git a/src/Umbraco.Web/UmbracoHelper.cs b/src/Umbraco.Web/UmbracoHelper.cs index b72cd8069c..7224955922 100644 --- a/src/Umbraco.Web/UmbracoHelper.cs +++ b/src/Umbraco.Web/UmbracoHelper.cs @@ -72,23 +72,23 @@ namespace Umbraco.Web // ensures that we can return the specified value [Obsolete("This method is only used in Obsolete properties")] T Ensure(T o) where T : class => o ?? throw new InvalidOperationException("This UmbracoHelper instance has not been initialized."); - - [Obsolete("Inject and use an instance of " + nameof(IUmbracoComponentRenderer) + " in the constructor for using it in classes or get it from Current in views")] + + [Obsolete("Inject and use an instance of " + nameof(IUmbracoComponentRenderer) + " in the constructor for using it in classes or get it from Current.UmbracoComponentRenderer in views.")] private IUmbracoComponentRenderer ComponentRenderer => Ensure(_componentRenderer); - [Obsolete("Inject and use an instance of " + nameof(ICultureDictionaryFactory) + " in the constructor instead")] + [Obsolete("Inject and use an instance of " + nameof(ICultureDictionaryFactory) + " in the constructor for using it in classes or get it from Current.CultureDictionaryFactory in views.")] private ICultureDictionaryFactory CultureDictionaryFactory => Ensure(_cultureDictionaryFactory); /// /// Gets the tag context. /// - [Obsolete("Inject and use an instance of " + nameof(ITagQuery) + " in the constructor instead")] + [Obsolete("Inject and use an instance of " + nameof(ITagQuery) + " in the constructor for using it in classes or get it from Current.TagQuery in views.")] public ITagQuery TagQuery => Ensure(_tagQuery); /// /// Gets the query context. /// - [Obsolete("Inject and use an instance of " + nameof(IPublishedContentQuery) + " in the constructor for using it in classes or get it from Current in views")] + [Obsolete("Inject and use an instance of " + nameof(IPublishedContentQuery) + " in the constructor for using it in classes or get it from Current.PublishedContentQuery in views")] public IPublishedContentQuery ContentQuery => Ensure(_publishedContentQuery); ///