Hi,
I have a sub-class of DelegateCommand which fails with an InvalidProgramException, "The Command Language Runtime detected an invalid program." when I call Execute.
My sub-class looks like this:
public class SaveOrderCommand : DelegateCommand<IOrder>
{
[Dependency]
public IOrderService OrderService { get; set; }
public SaveOrderCommand()
: base(p => this.ExecuteSaveOrder(p), p => this.CanExecuteSaveOrder(p))
{ }
public bool CanExecuteSaveOrder(IOrder order)
{
return true;
}
public void ExecuteSaveOrder(IOrder order)
{
if (order == null)
return;
IProductOrderService productSpecificOrderService = this.OrderService.RegisteredServices[order.GetType()] as IProductOrderService;
order = productSpecificOrderService.Save(order);
}
}
I can see that giving the base class references to methods in the sub-class might be an issue but if that's the issue, can anyone suggest a better implementation?