You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
2.0 KiB
50 lines
2.0 KiB
using BBWYB.Common.Extensions;
|
|
using BBWYB.Common.Http;
|
|
using BBWYB.Common.Models;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using System.Windows;
|
|
using WebTest.Models;
|
|
|
|
namespace WebTest
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
public IServiceProvider ServiceProvider { get; private set; }
|
|
public IConfiguration Configuration { get; private set; }
|
|
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
var gl = new GlobalContext();
|
|
//string userToken = string.Empty;
|
|
|
|
//齐越山鸡
|
|
//userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMzk1NzA4MjA4NjU1MzcyMjg4IiwidGVhbUlkIjoiMTc2MDk3MTY4ODk2NDUyNjA4MCIsInNvblRlYW1JZHMiOiIiLCJleHAiOjE3NDIxOTYxMDF9.pt1onwf4f4QKyuT1kFWtcRw8LZo9s64CmHqrdI4fD5k";
|
|
|
|
|
|
|
|
|
|
var applicationPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
var builder = new ConfigurationBuilder().SetBasePath(applicationPath).AddJsonFile("appSettings.json", false, true);
|
|
Configuration = builder.Build();
|
|
gl.UserToken = Configuration.GetSection("UserToken").Value;
|
|
gl.BBYWApiHost = Configuration.GetSection("BBWYApiHost").Value;
|
|
gl.MDSApiHost = Configuration.GetSection("MDSApiHost").Value;
|
|
IServiceCollection serviceCollection = new ServiceCollection();
|
|
serviceCollection.AddHttpClient();
|
|
|
|
serviceCollection.AddSingleton<RestApiService>();
|
|
serviceCollection.AddSingleton(gl);
|
|
serviceCollection.BatchRegisterServices(new Assembly[] { Assembly.Load("WebTest") }, typeof(IDenpendency));
|
|
serviceCollection.AddMapper(new MappingProfile());
|
|
ServiceProvider = serviceCollection.BuildServiceProvider();
|
|
base.OnStartup(e);
|
|
}
|
|
}
|
|
}
|
|
|