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;
|
|
|
|
|
|
|
|
|
|
public RepositoryFactory()
|
|
|
|
|
: this(false)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-09 13:17:19 +11:00
|
|
|
public RepositoryFactory(bool disableAllCache)
|
2013-09-18 12:54:06 +10:00
|
|
|
{
|
|
|
|
|
_disableAllCache = disableAllCache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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-06-28 13:28:03 +02:00
|
|
|
CreateTemplateRepository(uow)) { EnsureUniqueNaming = Umbraco.Core.Configuration.UmbracoSettings.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-07-04 11:22:59 +02:00
|
|
|
CreateMediaTypeRepository(uow)) { EnsureUniqueNaming = Umbraco.Core.Configuration.UmbracoSettings.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);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 09:24:05 -04:00
|
|
|
public virtual IStylesheetRepository CreateStylesheetRepository(IUnitOfWork uow, IDatabaseUnitOfWork db)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
2013-10-29 09:24:05 -04:00
|
|
|
return new StylesheetRepository(uow, db);
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
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,
|
2014-01-06 11:56:53 +11:00
|
|
|
//There's not many user types but we query on users all the time so the result needs to be cached
|
|
|
|
|
RuntimeCacheProvider.Current);
|
2013-08-14 16:12:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal virtual IUserRepository CreateUserRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
2014-01-23 18:44:41 +11:00
|
|
|
//TODO: Should we cache users? we did in the legacy API, might be a good idea considering the amount we query for the current user but will
|
|
|
|
|
// need to check that, in v7 with the new forms auth way we shouldn't be querying for a user a lot of times but now that we're wrapping in v6
|
|
|
|
|
// we need to ensure that the constant user lookups are cached!
|
2013-08-14 16:12:13 +02:00
|
|
|
return new UserRepository(
|
|
|
|
|
uow,
|
|
|
|
|
NullCacheProvider.Current,
|
|
|
|
|
CreateUserTypeRepository(uow));
|
|
|
|
|
}
|
|
|
|
|
|
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-09-02 15:53:09 +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
|
|
|
}
|