50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using MAX.Core.DependencyInjection;
|
|
using MAX.Core.Interfaces;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using Store.Modules.CloudProduct.Services;
|
|
using System.ComponentModel;
|
|
|
|
namespace Store.Modules.CloudProduct
|
|
{
|
|
|
|
public class Startup : IStartup
|
|
{
|
|
public int Priority => IntPriority.Normal;
|
|
|
|
public void Initialize()
|
|
{
|
|
}
|
|
|
|
public void Register(IServiceRegistrar registrar)
|
|
{
|
|
|
|
|
|
|
|
Func<IServiceProvider, IFreeSql> KJDFsqlFactory = r =>
|
|
{
|
|
var config = r.GetRequiredService<IConfiguration>();
|
|
var connection = config.GetValue<string>("CloudProductConnection");
|
|
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
|
.UseConnectionString(FreeSql.DataType.MySql, connection)
|
|
.UseAdoConnectionPool(true)
|
|
.Build();
|
|
return fsql;
|
|
};
|
|
registrar.RegisterSingleton<IFreeSql>("CloudProductConnection", (s, k) =>
|
|
{
|
|
return KJDFsqlFactory(s);
|
|
});
|
|
}
|
|
|
|
public async void Start(IServiceProvider serviceProvider)
|
|
{
|
|
var openSearchService = serviceProvider.GetRequiredService<OpenSearchService>();
|
|
await openSearchService.GetStatusAsync();
|
|
}
|
|
|
|
|
|
}
|
|
}
|