58 lines
2.3 KiB
C#
58 lines
2.3 KiB
C#
|
|
using Autofac;
|
|||
|
|
using SqlSugar;
|
|||
|
|
using SqlSugar.IOC;
|
|||
|
|
using WinformDevFarme;
|
|||
|
|
using WinformDevFramework.Core.Autofac;
|
|||
|
|
using WinformDevFramework.Core.Configuration;
|
|||
|
|
using WinformDevFramework.Core.Winform;
|
|||
|
|
|
|||
|
|
namespace WinformDevFramework
|
|||
|
|
{
|
|||
|
|
internal static class Program
|
|||
|
|
{
|
|||
|
|
public static IContainer Container { get; private set; }
|
|||
|
|
/// <summary>
|
|||
|
|
/// The main entry point for the application.
|
|||
|
|
/// </summary>
|
|||
|
|
[STAThread]
|
|||
|
|
static void Main()
|
|||
|
|
{
|
|||
|
|
ApplicationConfiguration.Initialize();
|
|||
|
|
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
var builder = new ContainerBuilder();
|
|||
|
|
// ע<><D7A2> SqlSugar <20><><EFBFBD><EFBFBD>
|
|||
|
|
builder.Register(c =>
|
|||
|
|
{
|
|||
|
|
var db = new SqlSugarClient(new ConnectionConfig
|
|||
|
|
{
|
|||
|
|
ConnectionString = AppSettingsConstVars.DbSqlConnection, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|||
|
|
DbType = AppSettingsConstVars.DbDbType == IocDbType.MySql.ToString() ? DbType.MySql : DbType.SqlServer,
|
|||
|
|
IsAutoCloseConnection = true,
|
|||
|
|
InitKeyType = InitKeyType.Attribute // <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ InitKeyType.Attribute
|
|||
|
|
});
|
|||
|
|
return db;
|
|||
|
|
}).As<ISqlSugarClient>().InstancePerLifetimeScope();
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
var baseType = typeof(Form);
|
|||
|
|
builder.RegisterAssemblyTypes(typeof(Program).Assembly)
|
|||
|
|
.Where(t => baseType.IsAssignableFrom(t) && t != baseType).AsImplementedInterfaces()
|
|||
|
|
.InstancePerDependency()
|
|||
|
|
.Named(t => t.Name, typeof(Form));
|
|||
|
|
builder.RegisterModule(new AutofacModuleRegister());
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Container = builder.Build();
|
|||
|
|
AppInfo.Container = Container;
|
|||
|
|
Application.Run(Container.ResolveNamed<Form>("FrmLogin"));
|
|||
|
|
}
|
|||
|
|
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs ex)
|
|||
|
|
{
|
|||
|
|
var result = MessageBox.Show("ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>˳<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>", "<22>쳣", MessageBoxButtons.YesNo);
|
|||
|
|
if (result == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
Application.Exit();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|