Esempio n. 1
0
        public ArchetypePublishedProperty(ArchetypePropertyModel property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            var preview = false;

            _property = property;
            _rawValue = property.Value;

            // #418 - need to wrap this in a try/catch to prevent orphaned properties from breaking everything
            try
            {
                _propertyType = property.CreateDummyPropertyType();

                if (_propertyType != null)
                {
                    _sourceValue = new Lazy <object>(() => _propertyType.ConvertDataToSource(_rawValue, preview));
                    _objectValue = new Lazy <object>(() => _propertyType.ConvertSourceToObject(_sourceValue.Value, preview));
                    _xpathValue  = new Lazy <object>(() => _propertyType.ConvertSourceToXPath(_sourceValue.Value, preview));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Warn <ArchetypePublishedProperty>(string.Format("Could not create an IPublishedProperty for property: {0} - the error was: {1}", property.Alias, ex.Message));
            }
        }
        public DetachedPublishedProperty(PublishedPropertyType propertyType, object value, bool isPreview)
        {
            _propertyType = propertyType;
            _isPreview    = isPreview;

            _rawValue = value;

            _sourceValue = new Lazy <object>(() => _propertyType.ConvertDataToSource(_rawValue, _isPreview));
            _objectValue = new Lazy <object>(() => _propertyType.ConvertSourceToObject(_sourceValue.Value, _isPreview));
            _xpathValue  = new Lazy <object>(() => _propertyType.ConvertSourceToXPath(_sourceValue.Value, _isPreview));
        }
        public PublishedEmbeddedContentProperty(PublishedPropertyType propertyType, object value, bool isPreview)
        {
            if (propertyType == null)
            {
                throw new ArgumentNullException(nameof(propertyType));
            }

            _propertyType = propertyType;
            _isPreview    = isPreview;

            DataValue = value;

            _sourceValue = new Lazy <object>(() => _propertyType.ConvertDataToSource(DataValue, _isPreview));
            _objectValue = new Lazy <object>(() => _propertyType.ConvertSourceToObject(_sourceValue.Value, _isPreview));
            _xpathValue  = new Lazy <object>(() => _propertyType.ConvertSourceToXPath(_sourceValue.Value, _isPreview));

            PropertyTypeAlias = propertyType.PropertyTypeAlias;
        }
Esempio n. 4
0
        public ArchetypePublishedProperty(ArchetypePropertyModel property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            var preview = false;

            _property = property;
            _rawValue = property.Value;

            _propertyType = property.CreateDummyPropertyType();

            if (_propertyType != null)
            {
                _sourceValue = new Lazy <object>(() => _propertyType.ConvertDataToSource(_rawValue, preview));
                _objectValue = new Lazy <object>(() => _propertyType.ConvertSourceToObject(_sourceValue.Value, preview));
                _xpathValue  = new Lazy <object>(() => _propertyType.ConvertSourceToXPath(_sourceValue.Value, preview));
            }
        }