using CloudGaming.Code.AppExtend;
using CloudGaming.Code.Contract;
using CloudGaming.Code.Filter;
using CloudGaming.Code.JY;
using CloudGaming.GameModel.Db.Db_Ext;
using HuanMeng.DotNetCore.CustomExtension;
using HuanMeng.DotNetCore.SwaggerUtile;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json.Serialization;
using Refit;
using System.Reflection;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddMemoryCache();
builder.Services.AddHttpClient();
builder.Services.AddHttpContextAccessor(); //添加httpContext注入访问

 
 
#region  automap
var mapperDomain = AppDomain.CurrentDomain.GetAssemblies().Where(it => it.FullName.Contains("HuanMeng") || it.FullName.Contains("CloudGaming.")).ToList();
Type type = typeof(T_App_Config);
if (type != null)
{
    Assembly assembly = Assembly.GetAssembly(type);
    if (!mapperDomain.Any(it => it.FullName == assembly.FullName))
    {
        mapperDomain.Add(assembly);
    }
}

builder.Services.AddAutoMapper(mapperDomain);
#endregion

await builder.AddAppConfigClient();
 
builder.Services.AddRazorPages();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapRazorPages();

app.Run();
