From f681b137c727f7dcdb7d3f5765af8b5b3048c2d9 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 25 Oct 2018 13:35:52 +0300 Subject: Implemented Job Outline. --- .../Converters/ObjectToPropertiesConverter.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ObjectToPropertiesConverter.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ObjectToPropertiesConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ObjectToPropertiesConverter.cs new file mode 100644 index 000000000..09e7b527a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ObjectToPropertiesConverter.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.MachineStudio.Developer.Converters +{ + public class ObjectToPropertiesConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + var properties = value.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => (!x.PropertyType.IsClass && !typeof(IEnumerable).IsAssignableFrom(x.PropertyType)) || x.PropertyType == typeof(String)).ToList(); + return properties.Select(x => new { x.Name, Value = x.GetValue(value) }); + } + else + { + return null; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} -- cgit v1.3.1