-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
It would be nice to have a generic Result parameter apart from the classic true / false result.
a quick thought is below.
public interface IDialogResult<T> : IDialogResult where T:class
{
T Entity { get;set; }
}and also it would be nice if you can make Result and IDialogParameters properties as protected so that if someone wants to create an extended version of IDialogResult then they can set those parameters from the constructor.
public class CustomerInfoResult : DialogResult, IDialogResult<string>
{
public CustomerInfoResult(IDialogResult result)
{
//this is not possible at the moment
Parameters = result.Parameters;
Result = result.Result;
}
public string Entity { get; set; }
}so I made it this way
public class CustomerInfoResult : IDialogResult<string>
{
public CustomerInfoResult(IDialogResult result)
{
Parameters = result.Parameters;
Result = result.Result;
}
public string Entity { get; set; }
public IDialogParameters Parameters { get; }
public bool? Result { get; }
}private void ExecuteShowDialog()
{
var message = "This is a message that should be shown in the dialog.";
//using the dialog service as-is
_dialogService.ShowDialog("NotificationDialog", new DialogParameters($"message={message}"), r =>
{
var customerResult = r as CustomerInfoResult;
if (!r.Result.HasValue)
Title = "Result is null";
else if (r.Result == true)
{
if (customerResult != null)
{
Title = $"Result is True";
Entity = customerResult.Entity;
}
}
else if (r.Result == false)
Title = "Result is False";
else
Title = "What the hell did you do?";
});
}Thanks in advance.
Metadata
Metadata
Assignees
Labels
No labels