Exemplo n.º 1
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));
            }
        private object?GetInterValue()
        {
            if (_interInitialized)
            {
                return(_interValue);
            }

            _interValue       = PropertyType.ConvertSourceToInter(Element, _sourceValue, IsPreviewing);
            _interInitialized = true;
            return(_interValue);
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        // this is always invoked from within a lock, so does not require its own lock
        private object GetInterValue(string culture, string segment)
        {
            if (culture == "" && segment == "")
            {
                if (_interInitialized)
                {
                    return(_interValue);
                }
                _interValue       = PropertyType.ConvertSourceToInter(_content, _sourceValue, _isPreviewing);
                _interInitialized = true;
                return(_interValue);
            }

            if (_sourceValues == null)
            {
                _sourceValues = new Dictionary <CompositeStringStringKey, SourceInterValue>();
            }

            var k = new CompositeStringStringKey(culture, segment);

            if (!_sourceValues.TryGetValue(k, out var vvalue))
            {
                _sourceValues[k] = vvalue = new SourceInterValue {
                    Culture = culture, Segment = segment, SourceValue = GetSourceValue(culture, segment)
                }
            }
            ;

            if (vvalue.InterInitialized)
            {
                return(vvalue.InterValue);
            }
            vvalue.InterValue       = PropertyType.ConvertSourceToInter(_content, vvalue.SourceValue, _isPreviewing);
            vvalue.InterInitialized = true;
            return(vvalue.InterValue);
        }