using BLWWSCore.SOAP;
using SoapCore;

namespace BLWWSCore
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);

            // Add services to the container.

            builder.Services.AddHttpContextAccessor();

            // 注册 SOAP 服务
            builder.Services.AddSoapCore();
            builder.Services.AddScoped<IWebServices, BLWWebServices>();

            // 如果使用 Mvc，还需要添加
            // services.AddMvc();
            builder.Services.AddControllers();

            var app = builder.Build();

            // Configure the HTTP request pipeline.

            app.UseRouting();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.UseSoapEndpoint<IWebServices>("/blwws.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
                endpoints.UseSoapEndpoint<Isyncstatus>("/syncstatus.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
            });

            app.MapControllers();

            app.Run();
        }
    }
}
