public RawValueProperty(IPublishedPropertyType propertyType, IPublishedElement content, object sourceValue, bool isPreviewing = false) : base(propertyType, PropertyCacheLevel.Unknown) // cache level is ignored { if (propertyType.Variations != ContentVariation.Nothing) { throw new ArgumentException("Property types with variations are not supported here.", nameof(propertyType)); } _sourceValue = sourceValue; var interValue = new Lazy <object>(() => PropertyType.ConvertSourceToInter(content, _sourceValue, isPreviewing)); _objectValue = new Lazy <object>(() => PropertyType.ConvertInterToObject(content, PropertyCacheLevel.Unknown, interValue.Value, isPreviewing)); _xpathValue = new Lazy <object>(() => PropertyType.ConvertInterToXPath(content, PropertyCacheLevel.Unknown, interValue.Value, isPreviewing)); }
public override object?GetXPathValue(string?culture = null, string?segment = null) { GetCacheLevels(out var cacheLevel, out var referenceCacheLevel); lock (_locko) { var cacheValues = GetCacheValues(cacheLevel); if (cacheValues.XPathInitialized) { return(cacheValues.XPathValue); } cacheValues.XPathValue = PropertyType.ConvertInterToXPath(Element, referenceCacheLevel, GetInterValue(), IsPreviewing); cacheValues.XPathInitialized = true; return(cacheValues.XPathValue); } }
public override object GetXPathValue(string culture = null, string segment = null) { _content.VariationContextAccessor.ContextualizeVariation(_variations, _content.Id, ref culture, ref segment); lock (_locko) { var cacheValues = GetCacheValues(PropertyType.CacheLevel).For(culture, segment); // initial reference cache level always is .Content const PropertyCacheLevel initialCacheLevel = PropertyCacheLevel.Element; if (cacheValues.XPathInitialized) { return(cacheValues.XPathValue); } cacheValues.XPathValue = PropertyType.ConvertInterToXPath(_content, initialCacheLevel, GetInterValue(culture, segment), _isPreviewing); cacheValues.XPathInitialized = true; return(cacheValues.XPathValue); } }