I have the following abstract Class
abstract public class FooActivator<T> where T : class
{
protected static Expression<Func<Foo, Bar<T>>> ChosenProperty
public void Activate(T Paramater)
{
using (var foo = new Foo)
{
foo.ChosenProperty.Method(Paramater) //Obviously wrong, How do you do this?
}
}
}
The Idea is that I can Inherit this base class, assign a new value to ChosenProperty in order to tell Activate Which property to call the method on.
Public Class MyClassFooActivator : FooActivator<MyClass>
{
new static Expression<Func<Foo, Bar<MyClass>>> ChosenProperty = x => x.PropertyOfTypeBarMyClass
}
and now Activate(MyClass Paramater) is ready to be called, and it will call it using
foo.PropertyOfTypeBarMyClass.Method(Paramater)
because that is the Property contained in the Expression.
Obviously I can't do foo.ChosenProperty.Method(Paramater), because ChosenProperty is a Variable of type Expression, but what would be the syntax for selecting whatever property of foo that has been selected by the Expression?