PageRenderTime 39ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/Main/src/DynamicDataDisplay/Converters/FourValuesMultiConverter.cs

#
C# | 41 lines | 35 code | 6 blank | 0 comment | 8 complexity | babe8b00f7f2cda4461b03def3c12275 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Data;
  6. using System.Windows;
  7. namespace Microsoft.Research.DynamicDataDisplay.Converters
  8. {
  9. public abstract class FourValuesMultiConverter<T1, T2, T3, T4> : IMultiValueConverter
  10. {
  11. #region IMultiValueConverter Members
  12. public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  13. {
  14. if (values != null && values.Length == 4)
  15. {
  16. if (values[0] is T1 && values[1] is T2 && values[2] is T3 && values[3] is T4)
  17. {
  18. T1 param1 = (T1)values[0];
  19. T2 param2 = (T2)values[1];
  20. T3 param3 = (T3)values[2];
  21. T4 param4 = (T4)values[3];
  22. var result = ConvertCore(param1, param2, param3, param4, targetType, parameter, culture);
  23. return result;
  24. }
  25. }
  26. return DependencyProperty.UnsetValue;
  27. }
  28. protected abstract object ConvertCore(T1 value1, T2 value2, T3 value3, T4 value4, Type targetType, object parameter, System.Globalization.CultureInfo culture);
  29. public virtual object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
  30. {
  31. throw new NotSupportedException();
  32. }
  33. #endregion
  34. }
  35. }