Files
Umbraco-CMS/src/Umbraco.Infrastructure/PublishedContentQueryAccessor.cs

24 lines
944 B
C#
Raw Normal View History

using System;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.DependencyInjection;
namespace Umbraco.Cms.Core
{
public class PublishedContentQueryAccessor : IPublishedContentQueryAccessor
{
private readonly IScopedServiceProvider _scopedServiceProvider;
[Obsolete("Please use alternative constructor")]
public PublishedContentQueryAccessor(IServiceProvider serviceProvider) => _scopedServiceProvider = serviceProvider.GetRequiredService<IScopedServiceProvider>();
public PublishedContentQueryAccessor(IScopedServiceProvider scopedServiceProvider) => _scopedServiceProvider = scopedServiceProvider;
2021-08-17 13:10:13 +02:00
public bool TryGetValue(out IPublishedContentQuery publishedContentQuery)
{
publishedContentQuery = _scopedServiceProvider.ServiceProvider?.GetService<IPublishedContentQuery>();
return publishedContentQuery is not null;
}
}
}