Created
May 30, 2018 20:50
-
-
Save bradoyler/729d49ef8e57ab8190f950a2fc2c0c8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public T ObjectAssign(T source) | |
{ | |
Type t = this.GetType(); | |
var properties = t.GetProperties().Where(prop => prop.CanRead && prop.CanWrite); | |
foreach (var prop in properties) | |
{ | |
var value = prop.GetValue(source, null); | |
if (value != null) | |
prop.SetValue(this, value, null); | |
} | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment