protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (UnitTestDetector.IsInUnitTest)
         {
             instanceCreatedForTDDOrConsoleApp = null;
         }
         else if (HttpContext.Current != null && (HttpContext.Current.Items[BUSINESS_FACADE_KEY] != null))
         {
             HttpContext.Current.Items[BUSINESS_FACADE_KEY] = null;
         }
     }
 }
        public static TAppBOFacade GetInstance <TAppBOFacade>() where TAppBOFacade : /*subclass of*/ BusinessFacadeBase <TContext>, new()
        {
            if (UnitTestDetector.IsInUnitTest)
            {
                if (instanceCreatedForTDDOrConsoleApp == null)
                {
                    instanceCreatedForTDDOrConsoleApp = new TAppBOFacade();
                }

                return((TAppBOFacade)instanceCreatedForTDDOrConsoleApp);
            }
            else if (HttpContext.Current != null)
            {
                if (HttpContext.Current.Items[BUSINESS_FACADE_KEY] == null)
                {
                    HttpContext.Current.Items[BUSINESS_FACADE_KEY] = new TAppBOFacade();
                }
                return((TAppBOFacade)HttpContext.Current.Items[BUSINESS_FACADE_KEY]);
            }
            else
            {
                return(null);
            }
        }