Fixes merge issue , fixes the ServiceContext lazy fields to be the underlying interfaces, adds public ctor
This commit is contained in:
@@ -12,42 +12,71 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
public class ServiceContext
|
||||
{
|
||||
private Lazy<ContentService> _contentService;
|
||||
private Lazy<UserService> _userService;
|
||||
private Lazy<MemberService> _memberService;
|
||||
private Lazy<MediaService> _mediaService;
|
||||
private Lazy<ContentTypeService> _contentTypeService;
|
||||
private Lazy<DataTypeService> _dataTypeService;
|
||||
private Lazy<FileService> _fileService;
|
||||
private Lazy<LocalizationService> _localizationService;
|
||||
private Lazy<IContentService> _contentService;
|
||||
private Lazy<IUserService> _userService;
|
||||
private Lazy<IMemberService> _memberService;
|
||||
private Lazy<IMediaService> _mediaService;
|
||||
private Lazy<IContentTypeService> _contentTypeService;
|
||||
private Lazy<IDataTypeService> _dataTypeService;
|
||||
private Lazy<IFileService> _fileService;
|
||||
private Lazy<ILocalizationService> _localizationService;
|
||||
private Lazy<PackagingService> _packagingService;
|
||||
private Lazy<ServerRegistrationService> _serverRegistrationService;
|
||||
private Lazy<EntityService> _entityService;
|
||||
private Lazy<RelationService> _relationService;
|
||||
private Lazy<MemberTypeService> _memberTypeService;
|
||||
private Lazy<IMemberTypeService> _memberTypeService;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="dbUnitOfWorkProvider"></param>
|
||||
/// <param name="fileUnitOfWorkProvider"></param>
|
||||
/// <param name="publishingStrategy"></param>
|
||||
internal ServiceContext(IDatabaseUnitOfWorkProvider dbUnitOfWorkProvider, IUnitOfWorkProvider fileUnitOfWorkProvider, BasePublishingStrategy publishingStrategy)
|
||||
{
|
||||
BuildServiceCache(dbUnitOfWorkProvider, fileUnitOfWorkProvider, publishingStrategy,
|
||||
//this needs to be lazy because when we create the service context it's generally before the
|
||||
//resolvers have been initialized!
|
||||
new Lazy<RepositoryFactory>(() => RepositoryResolver.Current.Factory));
|
||||
}
|
||||
/// <summary>
|
||||
/// public ctor - will generally just be used for unit testing
|
||||
/// </summary>
|
||||
/// <param name="contentService"></param>
|
||||
/// <param name="mediaService"></param>
|
||||
/// <param name="contentTypeService"></param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <param name="fileService"></param>
|
||||
/// <param name="localizationService"></param>
|
||||
/// <param name="packagingService"></param>
|
||||
/// <param name="serverRegistrationService"></param>
|
||||
/// <param name="entityService"></param>
|
||||
/// <param name="relationService"></param>
|
||||
/// <param name="memberTypeService"></param>
|
||||
public ServiceContext(Lazy<IContentService> contentService, Lazy<IMediaService> mediaService, Lazy<IContentTypeService> contentTypeService, Lazy<IDataTypeService> dataTypeService, Lazy<IFileService> fileService, Lazy<ILocalizationService> localizationService, Lazy<PackagingService> packagingService, Lazy<ServerRegistrationService> serverRegistrationService, Lazy<EntityService> entityService, Lazy<RelationService> relationService, Lazy<IMemberTypeService> memberTypeService)
|
||||
{
|
||||
_contentService = contentService;
|
||||
_mediaService = mediaService;
|
||||
_contentTypeService = contentTypeService;
|
||||
_dataTypeService = dataTypeService;
|
||||
_fileService = fileService;
|
||||
_localizationService = localizationService;
|
||||
_packagingService = packagingService;
|
||||
_serverRegistrationService = serverRegistrationService;
|
||||
_entityService = entityService;
|
||||
_relationService = relationService;
|
||||
_memberTypeService = memberTypeService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor used to instantiate the core services
|
||||
/// </summary>
|
||||
/// <param name="dbUnitOfWorkProvider"></param>
|
||||
/// <param name="fileUnitOfWorkProvider"></param>
|
||||
/// <param name="publishingStrategy"></param>
|
||||
internal ServiceContext(IDatabaseUnitOfWorkProvider dbUnitOfWorkProvider, IUnitOfWorkProvider fileUnitOfWorkProvider, BasePublishingStrategy publishingStrategy)
|
||||
{
|
||||
BuildServiceCache(dbUnitOfWorkProvider, fileUnitOfWorkProvider, publishingStrategy,
|
||||
//this needs to be lazy because when we create the service context it's generally before the
|
||||
//resolvers have been initialized!
|
||||
new Lazy<RepositoryFactory>(() => RepositoryResolver.Current.Factory));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the various services
|
||||
/// </summary>
|
||||
private void BuildServiceCache(
|
||||
IDatabaseUnitOfWorkProvider dbUnitOfWorkProvider,
|
||||
IUnitOfWorkProvider fileUnitOfWorkProvider,
|
||||
BasePublishingStrategy publishingStrategy,
|
||||
Lazy<RepositoryFactory> repositoryFactory)
|
||||
private void BuildServiceCache(
|
||||
IDatabaseUnitOfWorkProvider dbUnitOfWorkProvider,
|
||||
IUnitOfWorkProvider fileUnitOfWorkProvider,
|
||||
BasePublishingStrategy publishingStrategy,
|
||||
Lazy<RepositoryFactory> repositoryFactory)
|
||||
{
|
||||
var provider = dbUnitOfWorkProvider;
|
||||
var fileProvider = fileUnitOfWorkProvider;
|
||||
@@ -55,41 +84,41 @@ namespace Umbraco.Core.Services
|
||||
if (_serverRegistrationService == null)
|
||||
_serverRegistrationService = new Lazy<ServerRegistrationService>(() => new ServerRegistrationService(provider, repositoryFactory.Value));
|
||||
|
||||
if (_userService == null)
|
||||
_userService = new Lazy<UserService>(() => new UserService(provider, repositoryFactory.Value));
|
||||
if (_userService == null)
|
||||
_userService = new Lazy<IUserService>(() => new UserService(provider, repositoryFactory.Value));
|
||||
|
||||
if (_memberService == null)
|
||||
_memberService = new Lazy<MemberService>(() => new MemberService(provider, repositoryFactory.Value));
|
||||
_memberService = new Lazy<IMemberService>(() => new MemberService(provider, repositoryFactory.Value));
|
||||
|
||||
if (_contentService == null)
|
||||
_contentService = new Lazy<ContentService>(() => new ContentService(provider, repositoryFactory.Value, publishingStrategy));
|
||||
_contentService = new Lazy<IContentService>(() => new ContentService(provider, repositoryFactory.Value, publishingStrategy));
|
||||
|
||||
if(_mediaService == null)
|
||||
_mediaService = new Lazy<MediaService>(() => new MediaService(provider, repositoryFactory.Value));
|
||||
if (_mediaService == null)
|
||||
_mediaService = new Lazy<IMediaService>(() => new MediaService(provider, repositoryFactory.Value));
|
||||
|
||||
if(_contentTypeService == null)
|
||||
_contentTypeService = new Lazy<ContentTypeService>(() => new ContentTypeService(provider, repositoryFactory.Value, _contentService.Value, _mediaService.Value));
|
||||
if (_contentTypeService == null)
|
||||
_contentTypeService = new Lazy<IContentTypeService>(() => new ContentTypeService(provider, repositoryFactory.Value, _contentService.Value, _mediaService.Value));
|
||||
|
||||
if(_dataTypeService == null)
|
||||
_dataTypeService = new Lazy<DataTypeService>(() => new DataTypeService(provider, repositoryFactory.Value));
|
||||
if (_dataTypeService == null)
|
||||
_dataTypeService = new Lazy<IDataTypeService>(() => new DataTypeService(provider, repositoryFactory.Value));
|
||||
|
||||
if(_fileService == null)
|
||||
_fileService = new Lazy<FileService>(() => new FileService(fileProvider, provider, repositoryFactory.Value));
|
||||
if (_fileService == null)
|
||||
_fileService = new Lazy<IFileService>(() => new FileService(fileProvider, provider, repositoryFactory.Value));
|
||||
|
||||
if(_localizationService == null)
|
||||
_localizationService = new Lazy<LocalizationService>(() => new LocalizationService(provider, repositoryFactory.Value));
|
||||
if (_localizationService == null)
|
||||
_localizationService = new Lazy<ILocalizationService>(() => new LocalizationService(provider, repositoryFactory.Value));
|
||||
|
||||
if(_packagingService == null)
|
||||
if (_packagingService == null)
|
||||
_packagingService = new Lazy<PackagingService>(() => new PackagingService(_contentService.Value, _contentTypeService.Value, _mediaService.Value, _dataTypeService.Value, _fileService.Value, _localizationService.Value, repositoryFactory.Value, provider));
|
||||
|
||||
if (_entityService == null)
|
||||
_entityService = new Lazy<EntityService>(() => new EntityService(provider, repositoryFactory.Value, _contentService.Value, _contentTypeService.Value, _mediaService.Value, _dataTypeService.Value));
|
||||
|
||||
if(_relationService == null)
|
||||
if (_relationService == null)
|
||||
_relationService = new Lazy<RelationService>(() => new RelationService(provider, repositoryFactory.Value, _entityService.Value));
|
||||
|
||||
if (_memberTypeService == null)
|
||||
_memberTypeService = new Lazy<MemberTypeService>(() => new MemberTypeService(provider, repositoryFactory.Value));
|
||||
_memberTypeService = new Lazy<IMemberTypeService>(() => new MemberTypeService(provider, repositoryFactory.Value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -129,7 +158,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
public IContentTypeService ContentTypeService
|
||||
{
|
||||
get { return _contentTypeService.Value; }
|
||||
get { return _contentTypeService.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -137,7 +166,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
public IDataTypeService DataTypeService
|
||||
{
|
||||
get { return _dataTypeService.Value; }
|
||||
get { return _dataTypeService.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -145,7 +174,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
public IFileService FileService
|
||||
{
|
||||
get { return _fileService.Value; }
|
||||
get { return _fileService.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -153,7 +182,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
public ILocalizationService LocalizationService
|
||||
{
|
||||
get { return _localizationService.Value; }
|
||||
get { return _localizationService.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -161,7 +190,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
public IMediaService MediaService
|
||||
{
|
||||
get { return _mediaService.Value; }
|
||||
get { return _mediaService.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -177,7 +206,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
internal IUserService UserService
|
||||
{
|
||||
get { return _userService.Value; }
|
||||
get { return _userService.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -187,13 +216,14 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
get { return _memberService.Value; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MemberTypeService
|
||||
/// </summary>
|
||||
internal MemberTypeService MemberTypeService
|
||||
internal IMemberTypeService MemberTypeService
|
||||
{
|
||||
get { return _memberTypeService.Value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -719,11 +719,13 @@
|
||||
<Compile Include="Services\IMediaService.cs" />
|
||||
<Compile Include="Services\IMemberService.cs" />
|
||||
<Compile Include="Services\IMembershipUserService.cs" />
|
||||
<Compile Include="Services\IMemberTypeService.cs" />
|
||||
<Compile Include="Services\IService.cs" />
|
||||
<Compile Include="Services\IUserService.cs" />
|
||||
<Compile Include="Services\LocalizationService.cs" />
|
||||
<Compile Include="Services\MediaService.cs" />
|
||||
<Compile Include="Services\MemberService.cs" />
|
||||
<Compile Include="Services\MemberTypeService.cs" />
|
||||
<Compile Include="Services\RelationService.cs" />
|
||||
<Compile Include="Services\ServerRegistrationService.cs" />
|
||||
<Compile Include="Services\PackagingService.cs" />
|
||||
|
||||
Reference in New Issue
Block a user