In .NET, I have an instance of ConstructorInfo
. The declaring type is a constructed generic type (aka foo.DeclaringType.IsConstructedGenericType == true
). I want to retrieve the ConstructorInfo
instance that belongs to the open type - that is, the generic type definition of the declaring type.
It's straightforward to obtain the open type itself with foo.DeclaringType.GetGenericTypeDefinition()
; however, at this point, there is no obvious way to get the matching constructor. I can re-enumerate all constructors on both sides, but then, I am still facing the problem of matching those two lists together; and I am not sure that .NET provides any guarantees that the constructors will be enumerated in the same order.
Does anyone has a way to obtain the original ConstructorInfo
counterpart?
Aucun commentaire:
Enregistrer un commentaire