Assuming an Order(Aggregate class) with Credit Card class as a property. Depending on the state of Order I want to change the access modifier of the Credit Card class properties. For example: if Order state = Order.NewOrder, then allow Credit Card properties to be modifiable, however if Order state = Order.CompletedOrder, I do not want to allow the properties in Credit Card to be settable.
I want to be able to check at compile time vs run-time.
The only solution I thought of was to create 2 classes inheriting from the same parent class; one that allows properties to be settable the other not, but it gets hairy very quickly if there is a state that require some properties to be settable and others not.
Any ideas are greatly appreciated.