My code:
public abstract class Entity
{
// I need a method here
}
public abstract class ValueObject<T> where T : ValueObject<T>
{
}
public class User : Entity
{
public Password Password { get; private set; }
}
public class Password : ValueObject<Password>
{
}
I need a method in the Entity class that gets all properties of type ValueObject
[Edit 1]
I've tried something like this:
var properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
foreach(var property in properties)
{
var type = property.PropertyType;
if (property.PropertyType.IsSubclassOf(typeof(ValueObject<type>)) // Here is an error in "type"
{
// Here is other unnecessary things. Some things I already know how to do.
}
}