2021-08-04 12:48:19 +02:00
|
|
|
using System;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-11-15 13:23:02 +00:00
|
|
|
using Umbraco.Cms.Core.DependencyInjection;
|
2021-08-04 12:48:19 +02:00
|
|
|
|
|
|
|
|
namespace Umbraco.Cms.Core
|
|
|
|
|
{
|
|
|
|
|
public class PublishedContentQueryAccessor : IPublishedContentQueryAccessor
|
|
|
|
|
{
|
2021-11-15 13:23:02 +00:00
|
|
|
private readonly IScopedServiceProvider _scopedServiceProvider;
|
2021-08-04 12:48:19 +02:00
|
|
|
|
2021-11-15 13:23:02 +00:00
|
|
|
[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
|
|
|
|
2021-08-10 10:55:29 +02:00
|
|
|
public bool TryGetValue(out IPublishedContentQuery publishedContentQuery)
|
2021-08-04 12:48:19 +02:00
|
|
|
{
|
2021-11-15 13:23:02 +00:00
|
|
|
publishedContentQuery = _scopedServiceProvider.ServiceProvider?.GetService<IPublishedContentQuery>();
|
2021-08-10 10:55:29 +02:00
|
|
|
|
|
|
|
|
return publishedContentQuery is not null;
|
2021-08-04 12:48:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|