Last active
August 29, 2015 14:07
-
-
Save adrianratnapala/d4fc0351cd7594f05886 to your computer and use it in GitHub Desktop.
This file contains 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
// A table for finding the properties with common names in two C# types. | |
// the result can reduce boilerplate when you do copies, compares. | |
// etc between pairs of structurally similar types. E.g. a model -- controller | |
// transition. | |
// | |
// hat tip to http://stackoverflow.com/questions/3057178/linq-join-two-dictionaries-using-a-common-key | |
static Tuple<PropertyInfo, PropertyInfo>[] piPairs = ( | |
from mPi in typeof(Model.Component).GetProperties() | |
join pPi in typeof(ComponentRecord).GetProperties() | |
on mPi.Name equals pPi.Name | |
select Tuple.Create(mPi, pPi) | |
).ToArray(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment