Injecting derived classes

90 Views Asked by At

I have a problem using ValueInjecter for derived classes:

public class A
{
  public Guid Id { get; set; }
  public string Name { get; set; }
}

public class B : A
{
  public int Age { get; set; }
}

public static void main()
{
  var b = new B()
  {
    Id = Guid.NewGuid(),
    Name = "Test!",
    Age = 47
  };

  var a = new A();

  a.InjectFrom(b);

}

Injecter does not seem to copy the properties of the derived class.

I then tried to use the Clone convention and debugged the different calls to the methods, but I could not even see calls for the properties of the derived class. Only the properties directly on class A were called.

What am I doing wrong?

Best regards, Andreas Kroll

0

There are 0 best solutions below