using System;
namespace Umbraco.Core.Services
{
///
/// Represents the Umbraco Service context, which provides access to all services.
///
public class ServiceContext
{
private readonly Lazy _publicAccessService;
private readonly Lazy _domainService;
private readonly Lazy _auditService;
private readonly Lazy _localizedTextService;
private readonly Lazy _tagService;
private readonly Lazy _contentService;
private readonly Lazy _userService;
private readonly Lazy _memberService;
private readonly Lazy _mediaService;
private readonly Lazy _contentTypeService;
private readonly Lazy _mediaTypeService;
private readonly Lazy _dataTypeService;
private readonly Lazy _fileService;
private readonly Lazy _localizationService;
private readonly Lazy _packagingService;
private readonly Lazy _serverRegistrationService;
private readonly Lazy _entityService;
private readonly Lazy _relationService;
private readonly Lazy _macroService;
private readonly Lazy _memberTypeService;
private readonly Lazy _memberGroupService;
private readonly Lazy _notificationService;
private readonly Lazy _externalLoginService;
private readonly Lazy _redirectUrlService;
private readonly Lazy _consentService;
private readonly Lazy _contentTypeBaseServiceProvider;
///
/// Initializes a new instance of the class with lazy services.
///
public ServiceContext(Lazy publicAccessService, Lazy domainService, Lazy auditService, Lazy localizedTextService, Lazy tagService, Lazy contentService, Lazy userService, Lazy memberService, Lazy mediaService, Lazy contentTypeService, Lazy mediaTypeService, Lazy dataTypeService, Lazy fileService, Lazy localizationService, Lazy packagingService, Lazy serverRegistrationService, Lazy entityService, Lazy relationService, Lazy macroService, Lazy memberTypeService, Lazy memberGroupService, Lazy notificationService, Lazy externalLoginService, Lazy redirectUrlService, Lazy consentService, Lazy contentTypeBaseServiceProvider)
{
_publicAccessService = publicAccessService;
_domainService = domainService;
_auditService = auditService;
_localizedTextService = localizedTextService;
_tagService = tagService;
_contentService = contentService;
_userService = userService;
_memberService = memberService;
_mediaService = mediaService;
_contentTypeService = contentTypeService;
_mediaTypeService = mediaTypeService;
_dataTypeService = dataTypeService;
_fileService = fileService;
_localizationService = localizationService;
_packagingService = packagingService;
_serverRegistrationService = serverRegistrationService;
_entityService = entityService;
_relationService = relationService;
_macroService = macroService;
_memberTypeService = memberTypeService;
_memberGroupService = memberGroupService;
_notificationService = notificationService;
_externalLoginService = externalLoginService;
_redirectUrlService = redirectUrlService;
_consentService = consentService;
_contentTypeBaseServiceProvider = contentTypeBaseServiceProvider;
}
///
/// Creates a partial service context with only some services (for tests).
///
///
/// Using a true constructor for this confuses DI containers.
///
public static ServiceContext CreatePartial(
IContentService contentService = null,
IMediaService mediaService = null,
IContentTypeService contentTypeService = null,
IMediaTypeService mediaTypeService = null,
IDataTypeService dataTypeService = null,
IFileService fileService = null,
ILocalizationService localizationService = null,
IPackagingService packagingService = null,
IEntityService entityService = null,
IRelationService relationService = null,
IMemberGroupService memberGroupService = null,
IMemberTypeService memberTypeService = null,
IMemberService memberService = null,
IUserService userService = null,
ITagService tagService = null,
INotificationService notificationService = null,
ILocalizedTextService localizedTextService = null,
IAuditService auditService = null,
IDomainService domainService = null,
IMacroService macroService = null,
IPublicAccessService publicAccessService = null,
IExternalLoginService externalLoginService = null,
IServerRegistrationService serverRegistrationService = null,
IRedirectUrlService redirectUrlService = null,
IConsentService consentService = null,
IContentTypeBaseServiceProvider contentTypeBaseServiceProvider = null)
{
Lazy Lazy(T service) => service == null ? null : new Lazy(() => service);
return new ServiceContext(
Lazy(publicAccessService),
Lazy(domainService),
Lazy(auditService),
Lazy(localizedTextService),
Lazy(tagService),
Lazy(contentService),
Lazy(userService),
Lazy(memberService),
Lazy(mediaService),
Lazy(contentTypeService),
Lazy(mediaTypeService),
Lazy(dataTypeService),
Lazy(fileService),
Lazy(localizationService),
Lazy(packagingService),
Lazy(serverRegistrationService),
Lazy(entityService),
Lazy(relationService),
Lazy(macroService),
Lazy(memberTypeService),
Lazy(memberGroupService),
Lazy(notificationService),
Lazy(externalLoginService),
Lazy(redirectUrlService),
Lazy(consentService),
Lazy(contentTypeBaseServiceProvider)
);
}
///
/// Gets the
///
public IPublicAccessService PublicAccessService => _publicAccessService.Value;
///
/// Gets the
///
public IDomainService DomainService => _domainService.Value;
///
/// Gets the
///
public IAuditService AuditService => _auditService.Value;
///
/// Gets the
///
public ILocalizedTextService TextService => _localizedTextService.Value;
///
/// Gets the
///
public INotificationService NotificationService => _notificationService.Value;
///
/// Gets the
///
public IServerRegistrationService ServerRegistrationService => _serverRegistrationService.Value;
///
/// Gets the
///
public ITagService TagService => _tagService.Value;
///
/// Gets the
///
public IMacroService MacroService => _macroService.Value;
///
/// Gets the
///
public IEntityService EntityService => _entityService.Value;
///
/// Gets the
///
public IRelationService RelationService => _relationService.Value;
///
/// Gets the
///
public IContentService ContentService => _contentService.Value;
///
/// Gets the
///
public IContentTypeService ContentTypeService => _contentTypeService.Value;
///
/// Gets the
///
public IMediaTypeService MediaTypeService => _mediaTypeService.Value;
///
/// Gets the
///
public IDataTypeService DataTypeService => _dataTypeService.Value;
///
/// Gets the
///
public IFileService FileService => _fileService.Value;
///
/// Gets the
///
public ILocalizationService LocalizationService => _localizationService.Value;
///
/// Gets the
///
public IMediaService MediaService => _mediaService.Value;
///
/// Gets the
///
public IPackagingService PackagingService => _packagingService.Value;
///
/// Gets the
///
public IUserService UserService => _userService.Value;
///
/// Gets the
///
public IMemberService MemberService => _memberService.Value;
///
/// Gets the MemberTypeService
///
public IMemberTypeService MemberTypeService => _memberTypeService.Value;
///
/// Gets the MemberGroupService
///
public IMemberGroupService MemberGroupService => _memberGroupService.Value;
///
/// Gets the ExternalLoginService.
///
public IExternalLoginService ExternalLoginService => _externalLoginService.Value;
///
/// Gets the RedirectUrlService.
///
public IRedirectUrlService RedirectUrlService => _redirectUrlService.Value;
///
/// Gets the ConsentService.
///
public IConsentService ConsentService => _consentService.Value;
///
/// Gets the ContentTypeServiceBaseFactory.
///
public IContentTypeBaseServiceProvider ContentTypeBaseServices => _contentTypeBaseServiceProvider.Value;
}
}