static void Main(string[] args) { var siteStateContext = new SiteStateContext(); //set to Draft State siteStateContext.Approve(); //from Draft to Approved State //context.SoldOut(); var productStatuscontext = new ProductStateContext(siteStateContext); //set to Passive State productStatuscontext.Approve(); //from Passive to Active State //Sold the product siteStateContext.SoldOut(); productStatuscontext.SoldOut(); }
public ProductStateContext(SiteStateContext siteStatus) { CurrentState = new PassiveState(this, siteStatus); }
public DraftState(SiteStateContext siteStatusContext) { _siteStatusContext = siteStatusContext; }
public ArchivedState(SiteStateContext siteStatusContext) { _siteStatusContext = siteStatusContext; }
public PassiveState(ProductStateContext productStateContext, SiteStateContext siteStatusContext = null) { _productStateContext = productStateContext; _siteStatusContext = siteStatusContext; }
public ApprovedState(SiteStateContext siteStatusContext) { _siteStatusContext = siteStatusContext; }