PropertiesConverter.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using EventBus;
  2. namespace ActiveMQCommunication
  3. {
  4. static class PropertiesConverter
  5. {
  6. public static Dictionary<string,string> PropertiesToDic(this Properties properties)
  7. {
  8. if (properties == null || properties.Count ==0) return null;
  9. Dictionary<string, string> dic = new Dictionary<string, string>();
  10. foreach (var item in properties.Names)
  11. {
  12. dic[item] = properties[item];
  13. }
  14. return dic;
  15. }
  16. public static string PropertiesToselector(this Properties properties)
  17. {
  18. if (properties == null || properties.Count == 0) return string.Empty;
  19. string s = "";
  20. foreach(var val in properties.Names)
  21. {
  22. if(string.IsNullOrEmpty(s))
  23. {
  24. s = $"{val} = {properties[val]}";
  25. }
  26. else
  27. {
  28. s += $"and {val} = {properties[val]}";
  29. }
  30. }
  31. return s;
  32. }
  33. }
  34. }