Rename accessors

This commit is contained in:
Stephan
2018-04-30 21:29:49 +02:00
parent dbf310caf1
commit ff7c74ec8a
46 changed files with 182 additions and 182 deletions

View File

@@ -34,10 +34,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
DateTime createDate, int creatorId,
ContentData draftData, ContentData publishedData,
IPublishedSnapshotAccessor publishedSnapshotAccessor,
ICurrentVariationAccessor variationAccessor)
IVariationContextAccessor variationContextAccessor)
: this(id, uid, level, path, sortOrder, parentContentId, createDate, creatorId)
{
SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor, variationAccessor);
SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor, variationContextAccessor);
}
// 2-phases ctor, phase 1
@@ -59,7 +59,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
// two-phase ctor, phase 2
public void SetContentTypeAndData(PublishedContentType contentType, ContentData draftData, ContentData publishedData, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
public void SetContentTypeAndData(PublishedContentType contentType, ContentData draftData, ContentData publishedData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
{
ContentType = contentType;
@@ -67,9 +67,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
throw new ArgumentException("Both draftData and publishedData cannot be null at the same time.");
if (draftData != null)
Draft = new PublishedContent(this, draftData, publishedSnapshotAccessor, variationAccessor).CreateModel();
Draft = new PublishedContent(this, draftData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
if (publishedData != null)
Published = new PublishedContent(this, publishedData, publishedSnapshotAccessor, variationAccessor).CreateModel();
Published = new PublishedContent(this, publishedData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
}
// clone parent
@@ -98,7 +98,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
// clone with new content type
public ContentNode(ContentNode origin, PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
public ContentNode(ContentNode origin, PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
{
Id = origin.Id;
Uid = origin.Uid;
@@ -113,8 +113,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
var originDraft = origin.Draft == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Draft);
var originPublished = origin.Published == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Published);
Draft = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, publishedSnapshotAccessor, variationAccessor).CreateModel();
Published = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, publishedSnapshotAccessor, variationAccessor).CreateModel();
Draft = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
Published = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
ChildContentIds = origin.ChildContentIds; // can be the *same* list FIXME oh really?
}

View File

@@ -17,9 +17,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
public static ContentNodeKit Null { get; } = new ContentNodeKit { ContentTypeId = -1 };
public void Build(PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
public void Build(PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
{
Node.SetContentTypeAndData(contentType, DraftData, PublishedData, publishedSnapshotAccessor, variationAccessor);
Node.SetContentTypeAndData(contentType, DraftData, PublishedData, publishedSnapshotAccessor, variationContextAccessor);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// SnapDictionary has unit tests to ensure it all works correctly
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly ICurrentVariationAccessor _variationAccessor;
private readonly IVariationContextAccessor _variationContextAccessor;
private readonly ConcurrentDictionary<int, LinkedNode<ContentNode>> _contentNodes;
private readonly ConcurrentDictionary<int, LinkedNode<object>> _contentRootNodes;
private readonly ConcurrentDictionary<int, LinkedNode<PublishedContentType>> _contentTypesById;
@@ -44,10 +44,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
#region Ctor
public ContentStore(IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor, ILogger logger, BPlusTree<int, ContentNodeKit> localDb = null)
public ContentStore(IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, ILogger logger, BPlusTree<int, ContentNodeKit> localDb = null)
{
_publishedSnapshotAccessor = publishedSnapshotAccessor;
_variationAccessor = variationAccessor;
_variationContextAccessor = variationContextAccessor;
_logger = logger;
_localDb = localDb;
@@ -279,7 +279,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
if (node == null) continue;
var contentTypeId = node.ContentType.Id;
if (index.TryGetValue(contentTypeId, out PublishedContentType contentType) == false) continue;
SetValueLocked(_contentNodes, node.Id, new ContentNode(node, contentType, _publishedSnapshotAccessor, _variationAccessor));
SetValueLocked(_contentNodes, node.Id, new ContentNode(node, contentType, _publishedSnapshotAccessor, _variationContextAccessor));
}
}
finally
@@ -393,7 +393,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
_contentNodes.TryGetValue(id, out LinkedNode<ContentNode> link);
if (link?.Value == null)
continue;
var node = new ContentNode(link.Value, contentType, _publishedSnapshotAccessor, _variationAccessor);
var node = new ContentNode(link.Value, contentType, _publishedSnapshotAccessor, _variationContextAccessor);
SetValueLocked(_contentNodes, id, node);
if (_localDb != null) RegisterChange(id, node.ToKit());
}
@@ -416,7 +416,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
return false;
// and use
kit.Build(link.Value, _publishedSnapshotAccessor, _variationAccessor);
kit.Build(link.Value, _publishedSnapshotAccessor, _variationContextAccessor);
return true;
}

View File

@@ -16,7 +16,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
class MemberCache : IPublishedMemberCache, INavigableData
{
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
public readonly ICurrentVariationAccessor VariationAccessor;
public readonly IVariationContextAccessor VariationContextAccessor;
private readonly ICacheProvider _snapshotCache;
private readonly IMemberService _memberService;
private readonly IDataTypeService _dataTypeService;
@@ -24,11 +24,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
private readonly PublishedContentTypeCache _contentTypeCache;
private readonly bool _previewDefault;
public MemberCache(bool previewDefault, ICacheProvider snapshotCache, IMemberService memberService, IDataTypeService dataTypeService, ILocalizationService localizationService, PublishedContentTypeCache contentTypeCache, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
public MemberCache(bool previewDefault, ICacheProvider snapshotCache, IMemberService memberService, IDataTypeService dataTypeService, ILocalizationService localizationService, PublishedContentTypeCache contentTypeCache, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
{
_snapshotCache = snapshotCache;
_publishedSnapshotAccessor = publishedSnapshotAccessor;
VariationAccessor = variationAccessor;
VariationContextAccessor = variationContextAccessor;
_memberService = memberService;
_dataTypeService = dataTypeService;
_localizationService = localizationService;
@@ -65,14 +65,14 @@ namespace Umbraco.Web.PublishedCache.NuCache
var member = _memberService.GetById(memberId);
return member == null
? null
: PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationAccessor);
: PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationContextAccessor);
});
}
private IPublishedContent /*IPublishedMember*/ GetById(IMember member, bool previewing)
{
return GetCacheItem(CacheKeys.MemberCacheMember("ById", _previewDefault, member.Id), () =>
PublishedMember.Create(member, GetContentType(member.ContentTypeId), previewing, _publishedSnapshotAccessor, VariationAccessor));
PublishedMember.Create(member, GetContentType(member.ContentTypeId), previewing, _publishedSnapshotAccessor, VariationContextAccessor));
}
public IPublishedContent /*IPublishedMember*/ GetByProviderKey(object key)
@@ -107,7 +107,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
public IPublishedContent /*IPublishedMember*/ GetByMember(IMember member)
{
return PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationAccessor);
return PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationContextAccessor);
}
public IEnumerable<IPublishedContent> GetAtRoot(bool preview)
@@ -115,7 +115,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// because members are flat (not a tree) everything is at root
// because we're loading everything... let's just not cache?
var members = _memberService.GetAllMembers();
return members.Select(m => PublishedMember.Create(m, GetContentType(m.ContentTypeId), preview, _publishedSnapshotAccessor, VariationAccessor));
return members.Select(m => PublishedMember.Create(m, GetContentType(m.ContentTypeId), preview, _publishedSnapshotAccessor, VariationContextAccessor));
}
public XPathNavigator CreateNavigator()

View File

@@ -191,7 +191,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// use context values
// fixme CultureSegment?
var publishedVariationContext = _content.VariationAccessor?.CurrentVariation;
var publishedVariationContext = _content.VariationContextAccessor?.VariationContext;
if (culture == null) culture = _variations.Has(ContentVariation.CultureNeutral) ? publishedVariationContext?.Culture : "";
if (segment == null) segment = _variations.Has(ContentVariation.CultureNeutral) ? publishedVariationContext?.Segment : "";
}

View File

@@ -22,12 +22,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
#region Constructors
public PublishedContent(ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
public PublishedContent(ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
{
_contentNode = contentNode;
_contentData = contentData;
_publishedSnapshotAccessor = publishedSnapshotAccessor;
VariationAccessor = variationAccessor; // fixme why is this a property? should be be on the base class?
VariationContextAccessor = variationContextAccessor; // fixme why is this a property? should be be on the base class?
_urlSegment = _contentData.Name.ToUrlSegment();
IsPreviewing = _contentData.Published == false;
@@ -70,7 +70,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
{
_contentNode = contentNode;
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
VariationAccessor = origin.VariationAccessor;
VariationContextAccessor = origin.VariationContextAccessor;
_contentData = origin._contentData;
_urlSegment = origin._urlSegment;
@@ -86,7 +86,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
private PublishedContent(PublishedContent origin)
{
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
VariationAccessor = origin.VariationAccessor;
VariationContextAccessor = origin.VariationContextAccessor;
_contentNode = origin._contentNode;
_contentData = origin._contentData;
@@ -181,7 +181,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
if (!ContentType.Variations.Has(ContentVariation.CultureNeutral)) // fixme CultureSegment?
return _contentData.Name;
var culture = VariationAccessor.CurrentVariation.Culture;
var culture = VariationContextAccessor.VariationContext.Culture;
if (culture == "")
return _contentData.Name;
@@ -197,7 +197,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
if (!ContentType.Variations.Has(ContentVariation.CultureNeutral)) // fixme CultureSegment?
return _urlSegment;
var culture = VariationAccessor.CurrentVariation.Culture;
var culture = VariationContextAccessor.VariationContext.Culture;
if (culture == "")
return _urlSegment;
@@ -244,7 +244,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
{
// handle context culture
if (culture == null)
culture = VariationAccessor.CurrentVariation.Culture;
culture = VariationContextAccessor.VariationContext.Culture;
// no invariant culture infos
if (culture == "") return null;
@@ -397,7 +397,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
#region Internal
internal ICurrentVariationAccessor VariationAccessor { get; }
internal IVariationContextAccessor VariationContextAccessor { get; }
// used by navigable content
internal IPublishedProperty[] PropertiesArray { get; }

View File

@@ -15,13 +15,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
{
private readonly IMember _member;
private PublishedMember(IMember member, ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
: base(contentNode, contentData, publishedSnapshotAccessor, variationAccessor)
private PublishedMember(IMember member, ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
: base(contentNode, contentData, publishedSnapshotAccessor, variationContextAccessor)
{
_member = member;
}
public static IPublishedContent Create(IMember member, PublishedContentType contentType, bool previewing, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
public static IPublishedContent Create(IMember member, PublishedContentType contentType, bool previewing, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
{
var d = new ContentData
{
@@ -37,7 +37,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
member.Level, member.Path, member.SortOrder,
member.ParentId,
member.CreateDate, member.CreatorId);
return new PublishedMember(member, n, d, publishedSnapshotAccessor, variationAccessor).CreateModel();
return new PublishedMember(member, n, d, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
}
private static Dictionary<string, PropertyData[]> GetPropertyValues(PublishedContentType contentType, IMember member)

View File

@@ -43,7 +43,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
private readonly IMemberRepository _memberRepository;
private readonly IGlobalSettings _globalSettings;
private readonly ISiteDomainHelper _siteDomainHelper;
private readonly ISystemDefaultCultureAccessor _systemDefaultCultureAccessor;
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
// volatile because we read it with no lock
private volatile bool _isReady;
@@ -81,12 +81,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
public PublishedSnapshotService(Options options, MainDom mainDom, IRuntimeState runtime,
ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, IdkMap idkMap,
IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor,
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
ILogger logger, IScopeProvider scopeProvider,
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
ISystemDefaultCultureAccessor systemDefaultCultureAccessor,
IDefaultCultureAccessor defaultCultureAccessor,
IDataSource dataSource, IGlobalSettings globalSettings, ISiteDomainHelper siteDomainHelper)
: base(publishedSnapshotAccessor, variationAccessor)
: base(publishedSnapshotAccessor, variationContextAccessor)
{
//if (Interlocked.Increment(ref _singletonCheck) > 1)
// throw new Exception("Singleton must be instancianted only once!");
@@ -99,7 +99,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
_documentRepository = documentRepository;
_mediaRepository = mediaRepository;
_memberRepository = memberRepository;
_systemDefaultCultureAccessor = systemDefaultCultureAccessor;
_defaultCultureAccessor = defaultCultureAccessor;
_globalSettings = globalSettings;
_siteDomainHelper = siteDomainHelper;
@@ -145,13 +145,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
// stores are created with a db so they can write to it, but they do not read from it,
// stores need to be populated, happens in OnResolutionFrozen which uses _localDbExists to
// figure out whether it can read the dbs or it should populate them from sql
_contentStore = new ContentStore(publishedSnapshotAccessor, variationAccessor, logger, _localContentDb);
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationAccessor, logger, _localMediaDb);
_contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, _localContentDb);
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, _localMediaDb);
}
else
{
_contentStore = new ContentStore(publishedSnapshotAccessor, variationAccessor, logger);
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationAccessor, logger);
_contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger);
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger);
}
_domainStore = new SnapDictionary<int, Domain>();
@@ -996,7 +996,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
var memberTypeCache = new PublishedContentTypeCache(null, null, _serviceContext.MemberTypeService, _publishedContentTypeFactory, _logger);
var defaultCulture = _systemDefaultCultureAccessor.DefaultCulture;
var defaultCulture = _defaultCultureAccessor.DefaultCulture;
var domainCache = new DomainCache(domainSnap, defaultCulture);
var domainHelper = new DomainHelper(domainCache, _siteDomainHelper);
@@ -1004,7 +1004,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
{
ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, domainHelper, _globalSettings, _serviceContext.LocalizationService),
MediaCache = new MediaCache(previewDefault, mediaSnap, snapshotCache, elementsCache),
MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, _serviceContext.DataTypeService, _serviceContext.LocalizationService, memberTypeCache, PublishedSnapshotAccessor, VariationAccessor),
MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, _serviceContext.DataTypeService, _serviceContext.LocalizationService, memberTypeCache, PublishedSnapshotAccessor, VariationContextAccessor),
DomainCache = domainCache,
SnapshotCache = snapshotCache,
ElementsCache = elementsCache