JobDocumentSetDescriptionConverter.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Globalization;
  3. using System.Windows;
  4. using System.Windows.Data;
  5. using InABox.Core;
  6. namespace PRSDesktop
  7. {
  8. public class JobDocumentSetDescriptionConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type t, object parameter, CultureInfo culture)
  11. {
  12. try
  13. {
  14. if ((value == null) || String.Equals(value,""))
  15. return "";
  16. var description = Serialization.Deserialize<JobDocumentSetDescriptionBlock>(value.ToString());
  17. if (String.Equals(parameter, "ID"))
  18. return description.ID;
  19. if (String.Equals(parameter, "Code"))
  20. return description.Code;
  21. if (String.Equals(parameter, "Description"))
  22. return description.Description;
  23. return parameter.ToString();
  24. }
  25. catch (Exception e)
  26. {
  27. return e.Message;
  28. }
  29. }
  30. public object ConvertBack(object value, Type t, object parameter, CultureInfo culture)
  31. {
  32. return value.Equals(false) ? DependencyProperty.UnsetValue : parameter;
  33. }
  34. }
  35. }