60 lines
1.4 KiB
C#
60 lines
1.4 KiB
C#
using FreeSql;
|
|
using MAX.Core.DependencyInjection;
|
|
using MAX.Core.Interfaces;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Store.Framework
|
|
{
|
|
public class Startup : IStartup
|
|
{
|
|
public int Priority => int.MaxValue - 1;
|
|
|
|
public void Initialize()
|
|
{
|
|
|
|
}
|
|
|
|
public void Register(IServiceRegistrar registrar)
|
|
{
|
|
//Func<IServiceProvider, IFreeSql> userFsqlFactory = r =>
|
|
//{
|
|
// var config = r.GetRequiredService<IConfiguration>();
|
|
// var connection = config.GetConnectionString("UserConnection");
|
|
// IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
|
// .UseConnectionString(FreeSql.DataType.MySql, connection)
|
|
// .UseAdoConnectionPool(true)
|
|
// .Build();
|
|
// return fsql;
|
|
//};
|
|
//registrar.RegisterSingleton<IFreeSql>("UserDB", (s, k) =>
|
|
//{
|
|
// return userFsqlFactory(s);
|
|
//});
|
|
|
|
|
|
|
|
Func<IServiceProvider, IFreeSql> KJDFsqlFactory = r =>
|
|
{
|
|
var config = r.GetRequiredService<IConfiguration>();
|
|
var connection = config.GetConnectionString("KJDConnection");
|
|
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
|
.UseConnectionString(FreeSql.DataType.MySql, connection)
|
|
.UseAdoConnectionPool(true)
|
|
.Build();
|
|
return fsql;
|
|
};
|
|
registrar.RegisterSingleton<IFreeSql>("KJDDB", (s, k) =>
|
|
{
|
|
return KJDFsqlFactory(s);
|
|
});
|
|
}
|
|
|
|
public void Start(IServiceProvider serviceProvider)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|