I´m creating some instances of types that I do not know during compile-time. For this approach I searched for an alternative way then using Activator.CreateInstance
because the number of instances may increase heavily during development. I found this post for fast creation of those instances. The only problem I have is that I do not know the actual type to create instances from during compile-time. Of course I could use MethodInfo.MakeGenericMethod(myType)
and afterwards use method.Invoke
to invoke the received method. But as I read within the previously mentioned post calling Invoke
on constructors takes much time, so I wondered if this also applies to usual methods.
Thus it would be quite ambivalent to search for a fast approach for constructing an instance of a type but not for the best solution to receive this type. So is there a similar (probably also using Expression-trees)?
Aucun commentaire:
Enregistrer un commentaire