Beispiel #1
0
        // determines whether a property has value
        public override bool HasValue(string culture = null, string segment = null)
        {
            _content.VariationContextAccessor.ContextualizeVariation(_variations, _content.Id, ref culture, ref segment);

            var value    = GetSourceValue(culture, segment);
            var hasValue = PropertyType.IsValue(value, PropertyValueLevel.Source);

            if (hasValue.HasValue)
            {
                return(hasValue.Value);
            }

            lock (_locko)
            {
                value    = GetInterValue(culture, segment);
                hasValue = PropertyType.IsValue(value, PropertyValueLevel.Inter);
                if (hasValue.HasValue)
                {
                    return(hasValue.Value);
                }

                var cacheValues = GetCacheValues(PropertyType.CacheLevel).For(culture, segment);

                // initial reference cache level always is .Content
                const PropertyCacheLevel initialCacheLevel = PropertyCacheLevel.Element;

                if (!cacheValues.ObjectInitialized)
                {
                    cacheValues.ObjectValue       = PropertyType.ConvertInterToObject(_content, initialCacheLevel, value, _isPreviewing);
                    cacheValues.ObjectInitialized = true;
                }
                value = cacheValues.ObjectValue;
                return(PropertyType.IsValue(value, PropertyValueLevel.Object) ?? false);
            }
        }
        public override bool HasValue(string?culture = null, string?segment = null)
        {
            var hasValue = PropertyType.IsValue(_sourceValue, PropertyValueLevel.Source);

            if (hasValue.HasValue)
            {
                return(hasValue.Value);
            }

            GetCacheLevels(out var cacheLevel, out var referenceCacheLevel);

            lock (_locko)
            {
                var value = GetInterValue();
                hasValue = PropertyType.IsValue(value, PropertyValueLevel.Inter);
                if (hasValue.HasValue)
                {
                    return(hasValue.Value);
                }

                var cacheValues = GetCacheValues(cacheLevel);
                if (!cacheValues.ObjectInitialized)
                {
                    cacheValues.ObjectValue       = PropertyType.ConvertInterToObject(Element, referenceCacheLevel, value, IsPreviewing);
                    cacheValues.ObjectInitialized = true;
                }
                value = cacheValues.ObjectValue;
                return(PropertyType.IsValue(value, PropertyValueLevel.Object) ?? false);
            }
        }
Beispiel #3
0
            public override object GetValue(string culture = null, string segment = null)
            {
                // isPreviewing is true here since we want to preview anyway...
                const bool isPreviewing = true;
                var        source       = PropertyType.ConvertSourceToInter(_content, _sourceValue, isPreviewing);

                return(PropertyType.ConvertInterToObject(_content, PropertyCacheLevel.Unknown, source, isPreviewing));
            }
Beispiel #4
0
        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?GetValue(string?culture = null, string?segment = null)
        {
            GetCacheLevels(out var cacheLevel, out var referenceCacheLevel);

            lock (_locko)
            {
                var cacheValues = GetCacheValues(cacheLevel);
                if (cacheValues.ObjectInitialized)
                {
                    return(cacheValues.ObjectValue);
                }
                cacheValues.ObjectValue       = PropertyType.ConvertInterToObject(Element, referenceCacheLevel, GetInterValue(), IsPreviewing);
                cacheValues.ObjectInitialized = true;
                return(cacheValues.ObjectValue);
            }
        }
        public override object GetValue(string culture = null, string segment = null)
        {
            // NOT caching the source (intermediate) value since we'll never need it
            // everything in Xml cache is per-request anyways
            // also, properties should not be shared between requests and therefore
            // are single threaded, so the following code should be safe & fast

            if (_objectValueComputed)
            {
                return(_objectValue);
            }
            var inter = PropertyType.ConvertSourceToInter(_content, _sourceValue, _isPreviewing);

            // initial reference cache level always is .Content
            _objectValue         = PropertyType.ConvertInterToObject(_content, PropertyCacheLevel.Element, inter, _isPreviewing);
            _objectValueComputed = true;
            return(_objectValue);
        }
Beispiel #7
0
        public override object GetValue(string culture = null, string segment = null)
        {
            _content.VariationContextAccessor.ContextualizeVariation(_variations, _content.Id, ref culture, ref segment);

            object value;

            lock (_locko)
            {
                var cacheValues = GetCacheValues(PropertyType.CacheLevel).For(culture, segment);

                // initial reference cache level always is .Content
                const PropertyCacheLevel initialCacheLevel = PropertyCacheLevel.Element;

                if (cacheValues.ObjectInitialized)
                {
                    return(cacheValues.ObjectValue);
                }
                cacheValues.ObjectValue       = PropertyType.ConvertInterToObject(_content, initialCacheLevel, GetInterValue(culture, segment), _isPreviewing);
                cacheValues.ObjectInitialized = true;
                value = cacheValues.ObjectValue;
            }

            return(value);
        }
 public override object GetValue(string culture       = null, string segment = null) => PropertyType.ConvertInterToObject(_owner, ReferenceCacheLevel, InterValue, _preview);