41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Windows.ApplicationModel.Core;
|
|
using Windows.Security.Credentials;
|
|
|
|
namespace FoxTube.Core.Helpers
|
|
{
|
|
public static class Utils
|
|
{
|
|
/// <summary>
|
|
/// Terminates current application session
|
|
/// </summary>
|
|
public static void CloseApp() =>
|
|
CoreApplication.Exit();
|
|
|
|
/// <summary>
|
|
/// Restarts application
|
|
/// </summary>
|
|
public static void RestartApp() =>
|
|
RestartApp(null);
|
|
|
|
/// <summary>
|
|
/// Restarts application with specified parameters
|
|
/// </summary>
|
|
/// <param name="args">Parameters which will be provided to new application instance</param>
|
|
public static async void RestartApp(string args) =>
|
|
await CoreApplication.RequestRestartAsync(args ?? "");
|
|
|
|
public static void InitializeFailsafeProtocol()
|
|
{
|
|
Metrics.AddEvent("Failsafe protocol initiated");
|
|
Settings.ResetSettings();
|
|
PasswordVault passwordVault = new PasswordVault();
|
|
IReadOnlyList<PasswordCredential> credentialEntries = passwordVault.RetrieveAll();
|
|
foreach (PasswordCredential credential in credentialEntries)
|
|
passwordVault.Remove(credential);
|
|
RestartApp();
|
|
}
|
|
}
|
|
}
|