예제 #1
0
        public static XamlConvertResult TryConvertCache(ref ConvertCacheStore cacheStore, Type targetType)
        {
            if (targetType == null)
            {
                return(new XamlConvertResult(null, CreateException(cacheStore.Value, null, "Target type is not specified")));
            }

            if (cacheStore.CachedType == targetType)
            {
                return(new XamlConvertResult(cacheStore.CachedValue, null));
            }

            var actualValue = cacheStore.Value.IsUnset() ? null : cacheStore.Value;

            var result = TryConvertValue(actualValue, targetType);

            cacheStore.CachedValue = result.IsValid ? result.Result : targetType.CreateDefaultValue();

            if (CanCacheValueOfType(targetType))
            {
                cacheStore.CachedType = targetType;
            }

            return(result);
        }
예제 #2
0
 public static object ConvertCache(ref ConvertCacheStore cacheStore, Type targetType)
 {
     return(TryConvertCache(ref cacheStore, targetType).Result);
 }
예제 #3
0
 public XamlConvertCache(object value, Type targetType)
 {
     _cacheStore = new ConvertCacheStore(value);
     XamlStaticConverter.ConvertCache(ref _cacheStore, targetType);
 }
예제 #4
0
 public XamlConvertCache(object value)
 {
     _cacheStore = new ConvertCacheStore(value);
 }