jeudi 29 juillet 2021

c# constructor get 'base' part with reflection

I'm currently trying to parse public member of some random dll, i'm stuck in getting the base part of constructor with the reflection

public class MyClass: MySuperClass
 {
   public MyClass(Color color1, Color color2)
          : base(0.0f, 0.0f, 0.0f, 0.0f, color1, color2)
        {
           //...
        }
  }

From the Type i figure it how to get the constuctor and the parameters but not the call to parent class constructor ': base(0.0f, 0.0f, 0.0f, 0.0f, color1, color2)'

var MyType = typeof(MyClass);
foreach (ConstructorInfo MyConstructor in MyType.GetConstructors())
{
     var MyParameters = MyConstructor.GetParameters();

     //todo get base parameters ': base(0.0f, 0.0f, 0.0f, 0.0f, color1, color2)' ? 
}

Do you know if there is a way to get the list of parameters/value used in the parent constructor call ?





Aucun commentaire:

Enregistrer un commentaire