feat: add prism extension.

This commit is contained in:
rabbitism
2024-02-03 23:01:29 +08:00
parent 0f97da7ce8
commit 6cf169e1d7
8 changed files with 121 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
using Avalonia.Controls;
using Prism.Ioc;
using Ursa.Controls;
namespace Ursa.PrismExtension;
public class UrsaDialogService(IContainerExtension container) : IUrsaDialogService
{
public void ShowCustom(string viewName, object? vm, Window? owner = null, DialogOptions? options = null)
{
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
Dialog.ShowCustom(v, vm, owner, options);
}
public Task<DialogResult> ShowModal(string viewName, object? vm, Window? owner = null, DialogOptions? options = null)
{
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
return Dialog.ShowModal(v, vm, owner, options);
}
public Task<TResult?> ShowCustomModal<TResult>(string viewName, object? vm, Window? owner = null, DialogOptions? options = null)
{
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
return Dialog.ShowCustomModal<TResult>(v, vm, owner, options);
}
}