Esempio n. 1
0
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            if (targetTypes.Length != 2)
            {
                throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.Error_InsufficientTypeParameters, new object[1]
                {
                    (object)2
                }));
            }
            if (!(value is TTarget) && (value != null || typeof(TTarget).IsValueType))
            {
                throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.Error_ValueNotOfType, new object[1]
                {
                    (object)typeof(TTarget).FullName
                }));
            }
            MultiValueHelper.CheckType <TSource1>(targetTypes, 0);
            MultiValueHelper.CheckType <TSource2>(targetTypes, 1);
            TSource1 out1;
            TSource2 out2;

            this.ConvertBack((TTarget)value, out out1, out out2, parameter, culture);
            return(new object[2]
            {
                (object)out1,
                (object)out2
            });
        }
Esempio n. 2
0
 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
 {
     if (values.Length != 2)
     {
         throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.Error_InsufficientSourceParameters, new object[1]
         {
             (object)2
         }));
     }
     foreach (object obj in values)
     {
         if (obj == DependencyProperty.UnsetValue)
         {
             return((object)default(TTarget));
         }
     }
     MultiValueHelper.CheckValue <TSource1>(values, 0);
     MultiValueHelper.CheckValue <TSource2>(values, 1);
     if (!targetType.IsAssignableFrom(typeof(TTarget)))
     {
         throw new InvalidOperationException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.Error_TargetNotExtendingType, new object[1]
         {
             (object)typeof(TTarget).FullName
         }));
     }
     return((object)this.Convert((TSource1)values[0], (TSource2)values[1], parameter, culture));
 }