aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Core/ExtensionMethods
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-22 14:21:23 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-22 14:21:23 +0300
commit10692d6af49f30f6a4eb5054945a6368dd181022 (patch)
tree9c68c1ba303aeed3be03f18ed01f72563bed644a /Software/Visual_Studio/Tango.Core/ExtensionMethods
parent24149160c17fabe143f143de2796f9485d64410b (diff)
downloadTango-10692d6af49f30f6a4eb5054945a6368dd181022.tar.gz
Tango-10692d6af49f30f6a4eb5054945a6368dd181022.zip
Refactored Machine Versions Module !!!!
Embedded sqlexaminer.msi to repo. Implemented precompiled views ? Fixed an issue with RemoteDB DAL. Added Active field to hardware components.
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/ExtensionMethods')
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs
index 0ae7973a1..7d0c86e06 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs
@@ -74,6 +74,27 @@ public static class ObjectExtensions
}
/// <summary>
+ /// Maps the object properties values to the destination object.
+ /// </summary>
+ /// <param name="source">The source.</param>
+ /// <param name="destination">The destination.</param>
+ public static void MapPrimitivesTo(this object source, object destination, Func<PropertyInfo, bool> condition)
+ {
+ foreach (var prop in source.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsPrimitive))
+ {
+ var desProp = destination.GetType().GetProperty(prop.Name, BindingFlags.Public | BindingFlags.Instance);
+
+ if (desProp != null && desProp.PropertyType.IsPrimitive && desProp.SetMethod != null)
+ {
+ if (condition(prop))
+ {
+ desProp.SetValue(destination, prop.GetValue(source));
+ }
+ }
+ }
+ }
+
+ /// <summary>
/// Serializes the specified object to indented json string.
/// </summary>
/// <param name="obj">The object.</param>