From fdfa740288568dba27877a5ef5c817be323cfbb0 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 16 Jul 2018 13:47:20 +0300 Subject: Working on PPC. --- .../ExtensionMethods/ObjectExtensions.cs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Software/Visual_Studio/Tango.Core/ExtensionMethods') diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs index 135727735..9c5bc78e1 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs @@ -143,4 +143,27 @@ public static class ObjectExtensions return obj.ToString(); } } + + /// + /// Sets the property value by the specified path (e.g DateTime.Date.Days). + /// + /// The object. + /// The property path. + /// + public static void SetPropertyValueByPath(this object obj, String propertyPath, object value) + { + if (propertyPath != null) + { + if (propertyPath.Contains('.')) + { + string[] Split = propertyPath.Split('.'); + string RemainingProperty = propertyPath.Substring(propertyPath.IndexOf('.') + 1); + SetPropertyValueByPath(obj.GetType().GetProperty(Split[0]).GetValue(obj, null), RemainingProperty, value); + } + else + { + obj.GetType().GetProperty(propertyPath).SetValue(obj, value); + } + } + } } -- cgit v1.3.1