public T WithCacheOptions(CacheOptions options) { #if !SUPPORTS_CUSTOM_CACHE || WINDOWS_APP throw new PlatformNotSupportedException("WithCacheOptions is supported only on platforms where MSAL stores tokens in memory and not on mobile platforms or UWP."); #else Config.AccessorOptions = options; return((T)this); #endif }
public static void SetCacheOptions(this ITokenCache tokenCache, CacheOptions options) { ValidatePlatform(); TokenCache cache = (TokenCache)tokenCache; ITokenCacheInternal tokenCacheInternal = (ITokenCacheInternal)tokenCache; cache.ServiceBundle.Config.AccessorOptions = options; if (tokenCacheInternal.IsAppSubscribedToSerializationEvents()) { throw new MsalClientException( MsalError.StaticCacheWithExternalSerialization, MsalErrorMessage.StaticCacheWithExternalSerialization); } var proxy = cache.ServiceBundle?.PlatformProxy ?? PlatformProxyFactory.CreatePlatformProxy(null); cache.Accessor = proxy.CreateTokenCacheAccessor(options, tokenCacheInternal.IsApplicationCache); }