Skip to content

Commit

Permalink
chore: adding xml docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Jun 22, 2023
1 parent 2640a90 commit fe150e6
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/Prism.Core/Dialogs/DialogCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Prism.Dialogs;

/// <summary>
/// Provides a container for one or more Callbacks which may target specific Error Handling or Delegates to invoke on the successful close of the Dialog
/// </summary>
public readonly struct DialogCallback
{
private readonly bool _empty = false;
Expand All @@ -22,10 +25,20 @@ public DialogCallback()

private DialogCallback(bool empty) => _empty = empty;

/// <summary>
/// Invokes the Delegates based on a specific Exception that was encountered.
/// </summary>
/// <param name="ex"></param>
/// <returns></returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public Task Invoke(Exception ex) =>
Invoke(new DialogResult { Exception = ex });

/// <summary>
/// Invokes the Delegates for a given <see cref="IDialogResult"/>
/// </summary>
/// <param name="result">The Result</param>
/// <returns>A <see cref="Task"/>.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public async Task Invoke(IDialogResult result)
{
Expand Down
25 changes: 23 additions & 2 deletions src/Prism.Core/Dialogs/DialogCloseEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,52 @@

namespace Prism.Dialogs;

/// <summary>
/// Provides a type to manage the invocation of a callback to close the Dialog
/// </summary>
public struct DialogCloseEvent
{
private readonly MulticastDelegate _callback;

/// <summary>
/// Creates a default instance of the <see cref="DialogCloseEvent"/>
/// </summary>
public DialogCloseEvent()
{
_callback = null;
}

/// <summary>
/// Creates an instance of the <see cref="DialogCloseEvent"/> with an <see cref="Action{IDialogParameters}"/> callback.
/// </summary>
/// <param name="callback">The callback to invoke.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public DialogCloseEvent(Action<IDialogParameters> callback)
{
_callback = callback;
}

/// <summary>
/// Creates an instance of the <see cref="DialogCloseEvent"/> with an <see cref="Func{IDialogParameters, Task}"/> asynchronous callback.
/// </summary>
/// <param name="callback"></param>
[EditorBrowsable(EditorBrowsableState.Never)]
public DialogCloseEvent(Func<IDialogParameters, Task> callback)
{
_callback = callback;
}

/// <summary>
/// Invokes the initialized delegate with no <see cref="IDialogParameters"/>.
/// </summary>
public void Invoke() =>
Invoke(null);

public void Invoke(IDialogParameters parameters)
/// <summary>
/// Invokes the initialized delegate with the specified <see cref="IDialogParameters"/>.
/// </summary>
/// <param name="parameters">The <see cref="IDialogParameters"/>.</param>
public async void Invoke(IDialogParameters parameters)
{
parameters ??= new DialogParameters();

Expand All @@ -38,7 +59,7 @@ public void Invoke(IDialogParameters parameters)
actionCallback(parameters);
break;
case Func<IDialogParameters, Task> taskCallback:
taskCallback(parameters);
await taskCallback(parameters);
break;
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/Prism.Core/Dialogs/DialogException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,46 @@

namespace Prism.Dialogs;

/// <summary>
/// Represents errors that may occur within the <see cref="IDialogService"/>.
/// </summary>
public class DialogException : Exception
{
/// <summary>
/// The <see cref="DialogException"/> Message returned when an unexpected error occurred while displaying the dialog.
/// </summary>
public const string ShowDialog = "Error while displaying dialog";

/// <summary>
/// The <see cref="DialogException"/> Message returned when the CurrentPage must be a ContentPage
/// </summary>
/// <remarks>Xamarin.Forms &amp; Maui specific</remarks>
public const string RequiresContentPage = "The current page must be a ContentPage";

/// <summary>
/// The <see cref="DialogException"/> Message returned when the Current View is not host a Dialog
/// </summary>
public const string HostPageIsNotDialogHost = "The current page is not currently hosting a Dialog";

/// <summary>
/// The <see cref="DialogException"/> Message returned when CanClose returns false
/// </summary>
public const string CanCloseIsFalse = "CanClose returned false";

/// <summary>
/// The <see cref="DialogException"/> Message returned when No ViewModel can be found
/// </summary>
public const string NoViewModel = "No ViewModel could be found";

/// <summary>
/// The <see cref="DialogException"/> Message returned when the ViewModel does not implment IDialogAware.
/// </summary>
public const string ImplementIDialogAware = "The ViewModel does not implement IDialogAware";

/// <summary>
/// Initializes a new <see cref="DialogException"/> with a given message
/// </summary>
/// <param name="message"></param>
public DialogException(string message) : base(message)
{
}
Expand Down
10 changes: 10 additions & 0 deletions src/Prism.Core/Dialogs/DialogParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

namespace Prism.Dialogs;

/// <summary>
/// Provides a base implementation of <see cref="IDialogParameters"/>.
/// </summary>
public class DialogParameters : ParametersBase, IDialogParameters
{
/// <summary>
/// Initializes a new instance of <see cref="DialogParameters"/>.
/// </summary>
public DialogParameters()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="DialogParameters"/> based on a specified query string.
/// </summary>
/// <param name="query">A uri query string</param>
public DialogParameters(string query)
: base(query)
{
Expand Down
18 changes: 18 additions & 0 deletions src/Prism.Core/Dialogs/IDialogAware.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
namespace Prism.Dialogs;

/// <summary>
/// Provides a way for objects involved in Dialogs to be notified of Dialog activities.
/// </summary>
public interface IDialogAware
{
/// <summary>
/// Evaluates whether the Dialog is in a state that would allow the Dialog to Close
/// </summary>
/// <returns><c>true</c> if the Dialog can close</returns>
bool CanCloseDialog();

/// <summary>
/// Provides a callback to clean up resources or finalize tasks when the Dialog has been closed
/// </summary>
void OnDialogClosed();

/// <summary>
/// Initializes the state of the Dialog with provided DialogParameters
/// </summary>
/// <param name="parameters"></param>
void OnDialogOpened(IDialogParameters parameters);

/// <summary>
/// The <see cref="DialogCloseEvent"/> will be set by the <see cref="IDialogService"/> and can be called to
/// invoke the close of the Dialog.
/// </summary>
DialogCloseEvent RequestClose { get; set; }
}

0 comments on commit fe150e6

Please sign in to comment.