InspectionItemDescriptionConverterExtension.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using FISLib.Consultation;
  2. using System;
  3. using System.Globalization;
  4. using System.Windows.Data;
  5. using System.Windows.Markup;
  6. namespace FISSDKDemo.Extensions
  7. {
  8. class InspectionItemDescriptionConverterExtension : MarkupExtension
  9. {
  10. [ThreadStatic]
  11. private static InspectionItemDescriptionConverter _converter;
  12. public override object ProvideValue(IServiceProvider serviceProvider)
  13. {
  14. return _converter ?? (_converter = new InspectionItemDescriptionConverter());
  15. }
  16. private class InspectionItemDescriptionConverter : IValueConverter
  17. {
  18. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  19. {
  20. if (value is FISInspectionItemType fisInspectionItemType)
  21. {
  22. return InspectionItemDescriptionGenerator.GetInspectionItemDescription(fisInspectionItemType);
  23. }
  24. return string.Empty;
  25. }
  26. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  27. {
  28. throw new NotImplementedException();
  29. }
  30. }
  31. }
  32. }