Exemplo 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));
            }
        }
Exemplo n.º 2
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));
            }
        }
 /// <summary>
 /// Determines whether the property is empty.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <returns></returns>
 private bool IsEmptyProperty(ArchetypePropertyModel property)
 {
     return(property == null || property.Value == null || string.IsNullOrEmpty(property.Value.ToString()));
 }