コード例 #1
0
ファイル: GlyphButton.cs プロジェクト: musli/MagneticCrawler
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            if (targetTypes.Length != 2)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "", new object[]
                {
                    2
                }));
            }
            if (!(value is TTarget) && (value != null || typeof(TTarget).IsValueType))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "", new object[]
                {
                    typeof(TTarget).FullName
                }));
            }
            MultiValueHelper.CheckType <TSource1>(targetTypes, 0);
            MultiValueHelper.CheckType <TSource2>(targetTypes, 1);
            TSource1 tSource;
            TSource2 tSource2;

            this.ConvertBack((TTarget)((object)value), out tSource, out tSource2, parameter, culture);
            return(new object[]
            {
                tSource,
                tSource2
            });
        }
コード例 #2
0
ファイル: GlyphButton.cs プロジェクト: musli/MagneticCrawler
 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
 {
     if (values.Length != 2)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "", new object[]
         {
             2
         }));
     }
     for (int i = 0; i < values.Length; i++)
     {
         object obj = values[i];
         //if (obj == DependencyProperty.UnsetValue || obj == BindingOperations.DisconnectedSource)
         if (obj == DependencyProperty.UnsetValue)
         {
             return(default(TTarget));
         }
     }
     MultiValueHelper.CheckValue <TSource1>(values, 0);
     MultiValueHelper.CheckValue <TSource2>(values, 1);
     if (!targetType.IsAssignableFrom(typeof(TTarget)))
     {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "", new object[]
         {
             typeof(TTarget).FullName
         }));
     }
     return(this.Convert((TSource1)((object)values[0]), (TSource2)((object)values[1]), parameter, culture));
 }