aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Core/ExtensionMethods
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-16 13:47:20 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-16 13:47:20 +0300
commitfdfa740288568dba27877a5ef5c817be323cfbb0 (patch)
tree933ee1cb2769d43c982596f50ff8b7ec791f3be7 /Software/Visual_Studio/Tango.Core/ExtensionMethods
parentd376387fa28a2091a21e2fc7193812d1f8a40ef2 (diff)
downloadTango-fdfa740288568dba27877a5ef5c817be323cfbb0.tar.gz
Tango-fdfa740288568dba27877a5ef5c817be323cfbb0.zip
Working on PPC.
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/ExtensionMethods')
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs23
1 files changed, 23 insertions, 0 deletions
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();
}
}
+
+ /// <summary>
+ /// Sets the property value by the specified path (e.g DateTime.Date.Days).
+ /// </summary>
+ /// <param name="obj">The object.</param>
+ /// <param name="propertyPath">The property path.</param>
+ /// <returns></returns>
+ 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);
+ }
+ }
+ }
}