Implemented IoC container
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GirCore.Adw-1" Version="0.6.3" />
|
<PackageReference Include="GirCore.Adw-1" Version="0.6.3" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,9 +1,30 @@
|
|||||||
var application = Adw.Application.New("org.typomustakes.keychain", Gio.ApplicationFlags.FlagsNone);
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
application.OnActivate += (sender, args) =>
|
|
||||||
{
|
|
||||||
var window = new App.UI.MainWindow().Window;
|
|
||||||
window.Application = (Adw.Application)sender;
|
|
||||||
window.Show();
|
|
||||||
};
|
|
||||||
|
|
||||||
return application.RunWithSynchronizationContext(null);
|
namespace App;
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
private static ServiceProvider? provider;
|
||||||
|
|
||||||
|
static int Main()
|
||||||
|
{
|
||||||
|
provider = SetupServices();
|
||||||
|
|
||||||
|
var application = Adw.Application.New("org.typomustakes.keychain", Gio.ApplicationFlags.FlagsNone);
|
||||||
|
application.OnActivate += (sender, args) =>
|
||||||
|
{
|
||||||
|
var window = new App.UI.MainWindow().Window;
|
||||||
|
window.Application = (Adw.Application)sender;
|
||||||
|
window.Show();
|
||||||
|
};
|
||||||
|
|
||||||
|
return application.RunWithSynchronizationContext(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ServiceProvider SetupServices()
|
||||||
|
{
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
services.AddTransient<IPasswordStoreService, PasswordStoreService>();
|
||||||
|
return services.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,7 +61,6 @@ public class MainWindow
|
|||||||
shortcuts.Add(new PasswordStoreShortcut(displayName:"Default", path:Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"/.password_store"));
|
shortcuts.Add(new PasswordStoreShortcut(displayName:"Default", path:Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"/.password_store"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example of reactive property updates
|
|
||||||
public void UpdateShortcutName(PasswordStoreShortcut shortcut, string newName)
|
public void UpdateShortcutName(PasswordStoreShortcut shortcut, string newName)
|
||||||
{
|
{
|
||||||
shortcut.DisplayName = newName; // This will automatically update the UI row
|
shortcut.DisplayName = newName; // This will automatically update the UI row
|
||||||
|
|||||||
Reference in New Issue
Block a user