aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-11-01 09:51:35 +0200
committerShlomo Hecht <shlomo@twine-s.com>2018-11-01 09:51:35 +0200
commit6870a8915e7dd9b1a9cf42c0f155ebbbbb11f11a (patch)
tree4066e424c2df4fa8b32579a874d49064de9a41fe /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters
parenta6ab7a96762c8d70a325c0425af1b47f7a785bfc (diff)
parentf29cc9046f9e5bca367b7efafd3f2e0997c3cd04 (diff)
downloadTango-6870a8915e7dd9b1a9cf42c0f155ebbbbb11f11a.tar.gz
Tango-6870a8915e7dd9b1a9cf42c0f155ebbbbb11f11a.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ObjectToPropertiesConverter.cs33
1 files changed, 33 insertions, 0 deletions
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();
+ }
+ }
+}