protected static void Dispose(bool disposing) { if (disposing) { if (UnitTestDetector.IsInUnitTest) { instanceCreatedForTDDOrConsoleApp = null; } else if (HttpContext.Current != null && (HttpContext.Current.Items[REPOSITORY_FACADE_KEY] != null)) { HttpContext.Current.Items[REPOSITORY_FACADE_KEY] = null; } } }
public static TAppRepositoryFacade GetInstance <TAppRepositoryFacade>() where TAppRepositoryFacade : RepositoryFacadeBase <TContext>, new() { if (UnitTestDetector.IsInUnitTest) { if (instanceCreatedForTDDOrConsoleApp == null) { instanceCreatedForTDDOrConsoleApp = new TAppRepositoryFacade(); } return((TAppRepositoryFacade)instanceCreatedForTDDOrConsoleApp); } else if (HttpContext.Current != null) { if (HttpContext.Current.Items[REPOSITORY_FACADE_KEY] == null) { HttpContext.Current.Items[REPOSITORY_FACADE_KEY] = new TAppRepositoryFacade(); } return((TAppRepositoryFacade)HttpContext.Current.Items[REPOSITORY_FACADE_KEY]); } else { return(null); } }