This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Authentication; | |
using Microsoft.AspNetCore.Http; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Threading.Tasks; | |
namespace Management.Ui.Services | |
{ | |
public class TokenContainer | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddAuthentication(options => | |
{ | |
options.DefaultScheme = | |
CookieAuthenticationDefaults.AuthenticationScheme; | |
options.DefaultChallengeScheme = | |
OpenIdConnectDefaults.AuthenticationScheme; | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<string> CallServiceAsync(string token, string controller) | |
{ | |
var baseAddress = Constants.SampleApi; | |
var client = new HttpClient | |
{ | |
BaseAddress = new Uri(baseAddress) | |
}; | |
client.SetBearerToken(token); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ApplicationInstance | |
{ | |
/// <summary> Проверяет запущен ли уже экземпляр приложения </summary> | |
/// <returns>true - запущен, false - нет</returns> | |
public static bool CheckForSecondInstance() | |
{ | |
var startup_path = System.Reflection.Assembly.GetEntryAssembly()?.Location; | |
var startup_file_name = System.IO.Path.GetFileNameWithoutExtension(startup_path); | |
var processes_with_same_file = Process.GetProcessesByName(startup_file_name); | |
return processes_with_same_file.Length > 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class JsonInFile | |
{ | |
/// <summary> | |
/// Сохранение данных в файл | |
/// </summary> | |
public static async Task<bool> SaveToFileAsync<T>(string FilePath, T data) | |
{ | |
try | |
{ | |
using var file = File.Create(FilePath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class App | |
{ | |
public static bool IsDesignMode { get; private set; } = true; | |
private static IHost __Host; | |
public static IHost Host => __Host ??= Program.CreateHostBuilder(Environment.GetCommandLineArgs()).Build(); | |
protected override async void OnStartup(StartupEventArgs e) | |
{ |
OlderNewer