public static InMemoryCryptoProvider GetOrCreateProvider() { lock (s_lock) { var time = TimeService.GetUtcNow(); if (s_currentProvider != null && s_providerExpiration > time) { return(s_currentProvider); } s_currentProvider = new InMemoryCryptoProvider(); s_providerExpiration = TimeService.GetUtcNow() + KeyRotationInterval; return(s_currentProvider); } }
public static InMemoryCryptoProvider GetOrCreateProvider(/* for testing */ ITimeService timeService = null) { if (timeService == null) { timeService = new TimeService(); } lock (s_lock) { if (s_currentProvider != null && s_providerExpiration > timeService.GetUtcNow()) { return(s_currentProvider); } s_currentProvider = new InMemoryCryptoProvider(); s_providerExpiration = timeService.GetUtcNow() + s_expirationTimespan; return(s_currentProvider); } }
public static void Reset() { s_currentProvider = null; TimeService = new TimeService(); }