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)); }
public object ProvideValue(object value, Type targetPropertyType) { if (targetPropertyType == _cacheTargetType) { return(_convertedCache); } _convertedCache = XamlStaticConverter.ConvertValue(value, targetPropertyType); _cacheTargetType = targetPropertyType; return(_convertedCache); }
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; } }
public override string GetStringValue(PropertyItem <T> propertyItem) { var xamlConvertResult = XamlStaticConverter.TryConvertValue(propertyItem.Value, typeof(string)); return(xamlConvertResult.IsValid ? (string)xamlConvertResult.Result : string.Empty); }
public static object XamlConvert(this object value, Type targetType) { return(XamlStaticConverter.ConvertValue(value, targetType)); }
public object GetValue(Type targetType) { return(XamlStaticConverter.ConvertCache(ref _cacheStore, targetType)); }