Esempio n. 1
0
        // this is always invoked from within a lock, so does not require its own lock
        public CacheValue For(string?culture, string?segment)
        {
            if (culture == string.Empty && segment == string.Empty)
            {
                return(this);
            }

            if (_values == null)
            {
                _values = new Dictionary <CompositeStringStringKey, CacheValue>();
            }

            var k = new CompositeStringStringKey(culture, segment);

            if (!_values.TryGetValue(k, out CacheValue? value))
            {
                _values[k] = value = new CacheValue();
            }

            return(value);
        }
Esempio n. 2
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);
        }