Example #1
0
        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();
        }
Example #2
0
 public ProductStateContext(SiteStateContext siteStatus)
 {
     CurrentState = new PassiveState(this, siteStatus);
 }
Example #3
0
 public DraftState(SiteStateContext siteStatusContext)
 {
     _siteStatusContext = siteStatusContext;
 }
Example #4
0
 public ArchivedState(SiteStateContext siteStatusContext)
 {
     _siteStatusContext = siteStatusContext;
 }
Example #5
0
 public PassiveState(ProductStateContext productStateContext, SiteStateContext siteStatusContext = null)
 {
     _productStateContext = productStateContext;
     _siteStatusContext   = siteStatusContext;
 }
Example #6
0
 public ApprovedState(SiteStateContext siteStatusContext)
 {
     _siteStatusContext = siteStatusContext;
 }