优化窗体socpe使用
This commit is contained in:
parent
90e885ce70
commit
716eeca4bb
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Falcon.SugarCore.DbContextExtensions;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PrivateBox.DataContext;
|
using PrivateBox.DataContext;
|
||||||
using PrivateBox.Encryption;
|
using PrivateBox.Encryption;
|
||||||
@ -15,7 +16,6 @@ namespace PrivateBox
|
|||||||
public AppRunTimeSettings Settings { get; set; }
|
public AppRunTimeSettings Settings { get; set; }
|
||||||
|
|
||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认分组名
|
/// 默认分组名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -28,8 +28,13 @@ namespace PrivateBox
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool EnableRefreshKeyList = true;
|
private bool EnableRefreshKeyList = true;
|
||||||
|
|
||||||
public MainForm(IServiceProvider provider) {
|
public MainForm(IServiceScopeFactory factory) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
var serviceScope = factory.CreateScope();
|
||||||
|
this.FormClosing += (s,d) => {
|
||||||
|
serviceScope?.Dispose();
|
||||||
|
};
|
||||||
|
var provider = serviceScope.ServiceProvider;
|
||||||
this.Encrytion = provider.GetRequiredService<IEncryptionService>();
|
this.Encrytion = provider.GetRequiredService<IEncryptionService>();
|
||||||
this.Db = provider.GetRequiredService<DbContext>();
|
this.Db = provider.GetRequiredService<DbContext>();
|
||||||
this.Settings = provider.GetRequiredService<AppRunTimeSettings>();
|
this.Settings = provider.GetRequiredService<AppRunTimeSettings>();
|
||||||
@ -41,6 +46,7 @@ namespace PrivateBox
|
|||||||
RefreshKeyList();
|
RefreshKeyList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.lbKeyList.SelectedIndexChanged += LbKeyList_SelectedIndexChanged;
|
this.lbKeyList.SelectedIndexChanged += LbKeyList_SelectedIndexChanged;
|
||||||
this.clb_group.ItemCheck += (s,e) => {
|
this.clb_group.ItemCheck += (s,e) => {
|
||||||
this.BeginInvoke(new Action(() => {
|
this.BeginInvoke(new Action(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user