c# - How to instantiate a subtype inside a dynamic class? -


i'm using c# dynamic keyword , i've got instance need set property value.

however, property requires type have no access since generated assembly in memory wsdl.

how can create property instance dynamically?

there no such thing property instance; there is:

  • an instance of object
  • which has members (which may dynamic in case)
  • to want assign value

if don't know type of value in advance, need create object combination of reflection (from type) , perhaps dynamic. latter depends on whether underlying object actually dynamic, vs being regular type exposed via dynamic api. likewise, whether can assign value property via reflection - or whether must use dynamic api - depends on same. fortunately, there tools fastmember allow access arbitrary members (with names known @ runtime, not compile-time) identically 2 cases. if scenario complex, maybe give whirl.


Comments