mgravell / fast-member

Automatically exported from code.google.com/p/fast-member
Apache License 2.0
1.02k stars 137 forks source link

How to distinguish between string and custom class? #89

Closed wakaguaka closed 3 years ago

wakaguaka commented 3 years ago

Hello, I am using Fast-Member for a case where I need to dynamically import all properties into a "proxy class" generated runtime for a webservice call.

How could I distinguish between a system type and a custom class? "IsPrimitive" does not seem to work for this case at least (not sure if there are others)

object sourcevalue = sourceacc[source, sourcemember.Name]; targetacc[target, tm.Name] = sourcevalue;

On this small piece of code it fails when source value is a custom class (which I need to read all properties inside a nested call).

Hope I made myself clear about this matter,

Please let me know if you need all the code behind.

Cheers,

wakaguaka commented 3 years ago

Oops! Had a brain leak. Validating CreateNewSupported from FastMember.TypeAccessor does the trick. This piece of code works for my scenario:

code.txt