2013-09-13 18:11:20 +10:00
|
|
|
using Umbraco.Core.Configuration;
|
|
|
|
|
using Umbraco.Core.Configuration.UmbracoSettings;
|
2012-12-09 09:01:00 +05:00
|
|
|
using Umbraco.Core.Persistence.Caching;
|
|
|
|
|
using Umbraco.Core.Persistence.Repositories;
|
|
|
|
|
using Umbraco.Core.Persistence.UnitOfWork;
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Persistence
|
|
|
|
|
{
|
2012-12-10 08:44:17 -01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Used to instantiate each repository type
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class RepositoryFactory
|
|
|
|
|
{
|
2013-09-18 12:54:06 +10:00
|
|
|
private readonly bool _disableAllCache;
|
2013-09-16 17:39:45 +10:00
|
|
|
private readonly IUmbracoSettingsSection _settings;
|
2013-09-13 18:11:20 +10:00
|
|
|
|
2013-09-18 12:54:06 +10:00
|
|
|
public RepositoryFactory()
|
2013-09-25 19:23:41 +10:00
|
|
|
: this(false, UmbracoConfig.For.UmbracoSettings())
|
2013-09-13 18:11:20 +10:00
|
|
|
{
|
2013-09-18 12:54:06 +10:00
|
|
|
|
2013-09-13 18:11:20 +10:00
|
|
|
}
|
|
|
|
|
|
2013-09-18 13:26:09 +10:00
|
|
|
internal RepositoryFactory(bool disableAllCache)
|
2013-09-25 19:23:41 +10:00
|
|
|
: this(disableAllCache, UmbracoConfig.For.UmbracoSettings())
|
2013-09-18 13:26:09 +10:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-18 12:59:46 +10:00
|
|
|
internal RepositoryFactory(bool disableAllCache, IUmbracoSettingsSection settings)
|
2013-09-13 18:11:20 +10:00
|
|
|
{
|
2013-09-18 12:54:06 +10:00
|
|
|
_disableAllCache = disableAllCache;
|
2013-09-18 12:59:46 +10:00
|
|
|
_settings = settings;
|
|
|
|
|
|
2013-09-13 18:11:20 +10:00
|
|
|
}
|
|
|
|
|
|
2013-10-04 16:11:51 +10:00
|
|
|
public virtual ITagsRepository CreateTagsRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new TagsRepository(
|
|
|
|
|
uow,
|
|
|
|
|
_disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current);
|
|
|
|
|
}
|
2013-09-18 12:54:06 +10:00
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IContentRepository CreateContentRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new ContentRepository(
|
|
|
|
|
uow,
|
2013-09-18 12:54:06 +10:00
|
|
|
_disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current,
|
2012-12-10 08:44:17 -01:00
|
|
|
CreateContentTypeRepository(uow),
|
2013-10-04 17:13:57 +10:00
|
|
|
CreateTemplateRepository(uow),
|
|
|
|
|
CreateTagsRepository(uow)) { EnsureUniqueNaming = _settings.Content.EnsureUniqueNaming };
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IContentTypeRepository CreateContentTypeRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new ContentTypeRepository(
|
|
|
|
|
uow,
|
2013-09-18 12:54:06 +10:00
|
|
|
_disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current,
|
2012-12-10 08:44:17 -01:00
|
|
|
new TemplateRepository(uow, NullCacheProvider.Current));
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IDataTypeDefinitionRepository CreateDataTypeDefinitionRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new DataTypeDefinitionRepository(
|
|
|
|
|
uow,
|
|
|
|
|
NullCacheProvider.Current);
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IDictionaryRepository CreateDictionaryRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new DictionaryRepository(
|
|
|
|
|
uow,
|
2013-09-18 12:54:06 +10:00
|
|
|
_disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current,
|
2012-12-10 08:44:17 -01:00
|
|
|
CreateLanguageRepository(uow));
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual ILanguageRepository CreateLanguageRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new LanguageRepository(
|
|
|
|
|
uow,
|
2013-09-18 12:54:06 +10:00
|
|
|
_disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current);
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IMediaRepository CreateMediaRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new MediaRepository(
|
|
|
|
|
uow,
|
2013-09-18 12:54:06 +10:00
|
|
|
_disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current,
|
2013-09-13 18:11:20 +10:00
|
|
|
CreateMediaTypeRepository(uow)) { EnsureUniqueNaming = _settings.Content.EnsureUniqueNaming };
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IMediaTypeRepository CreateMediaTypeRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new MediaTypeRepository(
|
|
|
|
|
uow,
|
2013-09-18 12:54:06 +10:00
|
|
|
_disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current);
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IRelationRepository CreateRelationRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new RelationRepository(
|
|
|
|
|
uow,
|
|
|
|
|
NullCacheProvider.Current,
|
|
|
|
|
CreateRelationTypeRepository(uow));
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IRelationTypeRepository CreateRelationTypeRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new RelationTypeRepository(
|
|
|
|
|
uow,
|
|
|
|
|
NullCacheProvider.Current);
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IScriptRepository CreateScriptRepository(IUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new ScriptRepository(uow);
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IStylesheetRepository CreateStylesheetRepository(IUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new StylesheetRepository(uow);
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual ITemplateRepository CreateTemplateRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
2013-09-18 12:54:06 +10:00
|
|
|
return new TemplateRepository(uow, _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current);
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
2013-08-14 16:12:13 +02:00
|
|
|
|
|
|
|
|
internal virtual ServerRegistrationRepository CreateServerRegistrationRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new ServerRegistrationRepository(
|
|
|
|
|
uow,
|
|
|
|
|
NullCacheProvider.Current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal virtual IUserTypeRepository CreateUserTypeRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new UserTypeRepository(
|
|
|
|
|
uow,
|
|
|
|
|
NullCacheProvider.Current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal virtual IUserRepository CreateUserRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new UserRepository(
|
|
|
|
|
uow,
|
|
|
|
|
NullCacheProvider.Current,
|
|
|
|
|
CreateUserTypeRepository(uow));
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 20:19:27 +10:00
|
|
|
internal virtual IMacroRepository CreateMacroRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
2013-09-20 13:40:32 +10:00
|
|
|
return new MacroRepository(uow, _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current);
|
2013-09-17 20:19:27 +10:00
|
|
|
}
|
|
|
|
|
|
2013-08-26 16:59:41 +02:00
|
|
|
internal virtual IMemberRepository CreateMemberRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
2013-09-18 12:54:06 +10:00
|
|
|
return new MemberRepository(uow, _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current, CreateMemberTypeRepository(uow));
|
2013-08-26 16:59:41 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-02 15:53:09 +02:00
|
|
|
internal virtual IMemberTypeRepository CreateMemberTypeRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
2013-09-18 12:54:06 +10:00
|
|
|
return new MemberTypeRepository(uow, _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current);
|
2013-08-26 16:59:41 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-14 16:12:13 +02:00
|
|
|
internal virtual IEntityRepository CreateEntityRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new EntityRepository(uow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal virtual RecycleBinRepository CreateRecycleBinRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new RecycleBinRepository(uow);
|
|
|
|
|
}
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
2012-12-09 09:01:00 +05:00
|
|
|
}
|