aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Core/ExtensionMethods
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-03-05 14:53:49 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-03-05 14:53:49 +0200
commit499f4facfe296d984a44e9ce0b6e1eb23ba8d644 (patch)
treebf554330362404128c36321a4fce3fd927caea82 /Software/Visual_Studio/Tango.Core/ExtensionMethods
parentb292fb7ff234a973670ebf9e54b9e111a90f3639 (diff)
downloadTango-499f4facfe296d984a44e9ce0b6e1eb23ba8d644.tar.gz
Tango-499f4facfe296d984a44e9ce0b6e1eb23ba8d644.zip
Improvements and bug fixes on PPC.
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/ExtensionMethods')
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs20
1 files changed, 20 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs
index 0ce3e8369..ce907b57b 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs
@@ -97,6 +97,26 @@ public static class ObjectExtensions
}
/// <summary>
+ /// Maps the object properties values to the destination object including strings and without assigning null string values from the source.
+ /// </summary>
+ /// <param name="source">The source.</param>
+ /// <param name="destination">The destination.</param>
+ public static void MapPrimitivesWithStrings(this object source, object destination)
+ {
+ foreach (var prop in source.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsPrimitive || x.PropertyType == typeof(String)))
+ {
+ var desProp = destination.GetType().GetProperty(prop.Name, BindingFlags.Public | BindingFlags.Instance);
+
+ if (desProp != null && (desProp.PropertyType.IsPrimitive || desProp.PropertyType == typeof(String)) && desProp.SetMethod != null)
+ {
+ var value = prop.GetValue(source);
+
+ desProp.SetValue(destination, value);
+ }
+ }
+ }
+
+ /// <summary>
/// Maps the object properties values to the destination object.
/// </summary>
/// <param name="source">The source.</param>