Example #1
0
        public static bool Compare(object sourceValue, object targetValue, ITriggerValueComparer comparer)
        {
            var actualComparer = comparer ?? XamlValueComparer.TriggerComparer;

            var actualSourceValue = sourceValue;
            var actualTargetValue = XamlStaticConverter.ConvertValue(targetValue, sourceValue?.GetType() ?? typeof(object));

            return(actualComparer.Compare(actualSourceValue, actualTargetValue));
        }
Example #2
0
        public object ProvideValue(object value, Type targetPropertyType)
        {
            if (targetPropertyType == _cacheTargetType)
            {
                return(_convertedCache);
            }

            _convertedCache  = XamlStaticConverter.ConvertValue(value, targetPropertyType);
            _cacheTargetType = targetPropertyType;

            return(_convertedCache);
        }
Example #3
0
        public override void SetStringValue(PropertyItem <T> propertyItem, string value)
        {
            var xamlConvertResult = XamlStaticConverter.TryConvertValue(value, typeof(T));

            if (xamlConvertResult.IsValid)
            {
                propertyItem.Value = (T)xamlConvertResult.Result;
            }
            else
            {
                throw xamlConvertResult.Exception.InnerException ?? xamlConvertResult.Exception;
            }
        }
Example #4
0
        public override string GetStringValue(PropertyItem <T> propertyItem)
        {
            var xamlConvertResult = XamlStaticConverter.TryConvertValue(propertyItem.Value, typeof(string));

            return(xamlConvertResult.IsValid ? (string)xamlConvertResult.Result : string.Empty);
        }
Example #5
0
 public static object XamlConvert(this object value, Type targetType)
 {
     return(XamlStaticConverter.ConvertValue(value, targetType));
 }
Example #6
0
 public object GetValue(Type targetType)
 {
     return(XamlStaticConverter.ConvertCache(ref _cacheStore, targetType));
 }