public void WriteAllBytes(byte[] bytes) { if (bytes != null) { _file.WriteAllBytes(ProtectedData.Protect(bytes, null, DataProtectionScope.CurrentUser)); } else { _file.WriteAllBytes(null); } }
// Triggered right after ADAL accessed the cache. private void AfterAccessNotification(TokenCacheNotificationArgs args) { // if the access operation resulted in a cache update if (HasStateChanged) { // reflect changes in the persistent store _settingsFile.WriteAllBytes(Serialize()); // once the write operation took place, restore the HasStateChanged bit to false HasStateChanged = false; } }