Skip to content

Commit

Permalink
Added documenation for:
Browse files Browse the repository at this point in the history
ApplicationStore.cs
EventToCommandBehavior.cs
IApplicationLifecycleAware.cs
IApplicationStore.cs
RuntimePlatform.cs
  • Loading branch information
d3fkn1ght committed Apr 28, 2020
1 parent ba493ca commit 72f1a35
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Forms/Prism.Forms/AppModel/ApplicationStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@

namespace Prism.AppModel
{
/// <summary>
/// Implementation of <see cref="IApplicationStore"/>
/// </summary>
public class ApplicationStore : IApplicationStore
{
/// <summary>
/// Getter for the current ApplicationStore properties
/// <see cref="IApplicationStore.Properties"/>
/// </summary>
public IDictionary<string, object> Properties
{
get { return Application.Current.Properties; }
}

/// <summary>
/// Asynchronously persists the Application.Properties dictionary for the application object.
/// </summary>
/// <returns>A task that represents the asynchronous save operation
/// <see cref="IApplicationStore.SavePropertiesAsync"/></returns>
public Task SavePropertiesAsync() =>
Application.Current.SavePropertiesAsync();
}
Expand Down
9 changes: 9 additions & 0 deletions src/Forms/Prism.Forms/AppModel/IApplicationLifecycleAware.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
namespace Prism.AppModel
{
/// <summary>
/// Interface to handle OS related events when Application is put to sleep, etc.
/// </summary>
public interface IApplicationLifecycleAware
{
/// <summary>
/// Called when application is resumed
/// </summary>
void OnResume();

/// <summary>
/// Called when application is put to sleep
/// </summary>
void OnSleep();
}
}
11 changes: 11 additions & 0 deletions src/Forms/Prism.Forms/AppModel/IApplicationStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@

namespace Prism.AppModel
{
/// <summary>
/// Interface for an Application Store to save/load properties of Application
/// </summary>
public interface IApplicationStore
{
/// <summary>
/// Getter for properties
/// </summary>
IDictionary<string, object> Properties { get; }

/// <summary>
/// Asynchronously persists the Application.Properties dictionary for the application object.
/// </summary>
/// <returns>A task that represents the asynchronous save operation
/// <see cref="IApplicationStore.SavePropertiesAsync"/></returns>
Task SavePropertiesAsync();
}
}
31 changes: 31 additions & 0 deletions src/Forms/Prism.Forms/AppModel/RuntimePlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,44 @@
/// <remarks>This enum acts as a wrapper around the Device.RuntimePlatform string-based options</remarks>
public enum RuntimePlatform
{
/// <summary>
/// Google Android
/// </summary>
Android,

/// <summary>
/// GTK UI projects
/// </summary>
GTK,

/// <summary>
/// Apple IOS
/// </summary>
iOS,

/// <summary>
/// Apple macOS
/// </summary>
macOS,

/// <summary>
/// Tizen OS
/// </summary>
Tizen,

/// <summary>
/// Universal Windows Platform
/// </summary>
UWP,

/// <summary>
/// Windows Presentation Foundation
/// </summary>
WPF,

/// <summary>
/// Catchall for unlisted Platform
/// </summary>
Unknown
}
}
41 changes: 41 additions & 0 deletions src/Forms/Prism.Forms/Behaviors/EventToCommandBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,54 @@ namespace Prism.Behaviors
// This is a modified version of https://anthonysimmon.com/eventtocommand-in-xamarin-forms-apps/
public class EventToCommandBehavior : BehaviorBase<BindableObject>
{
/// <summary>
/// Bindable property for Name of the event that will be forwarded to
/// <see cref="EventToCommandBehavior.Command"/>
/// </summary>
public static readonly BindableProperty EventNameProperty =
BindableProperty.Create(nameof(EventName), typeof(string), typeof(EventToCommandBehavior));

/// <summary>
/// Bindable property for Command to execute
/// </summary>
public static readonly BindableProperty CommandProperty =
BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(EventToCommandBehavior));

/// <summary>
/// Bindable property for Argument sent to <see cref="ICommand.Execute(object)"/>
/// </summary>
public static readonly BindableProperty CommandParameterProperty =
BindableProperty.Create(nameof(CommandParameter), typeof(object), typeof(EventToCommandBehavior));

/// <summary>
/// Bindable property to set instance of <see cref="IValueConverter" /> to convert the <see cref="EventArgs" /> for <see cref="EventName" />
/// </summary>
public static readonly BindableProperty EventArgsConverterProperty =
BindableProperty.Create(nameof(EventArgsConverter), typeof(IValueConverter), typeof(EventToCommandBehavior));

/// <summary>
/// Bindable property to set Argument passed as parameter to <see cref="IValueConverter.Convert" />
/// </summary>
public static readonly BindableProperty EventArgsConverterParameterProperty =
BindableProperty.Create(nameof(EventArgsConverterParameter), typeof(object), typeof(EventToCommandBehavior));

/// <summary>
/// Bindable property to set Parameter path to extract property from <see cref="EventArgs"/> instance to pass to <see cref="ICommand.Execute"/>
/// </summary>
public static readonly BindableProperty EventArgsParameterPathProperty =
BindableProperty.Create(
nameof(EventArgsParameterPath),
typeof(string),
typeof(EventToCommandBehavior));

/// <summary>
/// <see cref="EventInfo"/>
/// </summary>
protected EventInfo _eventInfo;

/// <summary>
/// Delegate to Invoke when event is raised
/// </summary>
protected Delegate _handler;

/// <summary>
Expand Down Expand Up @@ -120,6 +146,12 @@ public object EventArgsConverterParameter
set { SetValue(EventArgsConverterParameterProperty, value); }
}

/// <summary>
/// Subscribes to the event <see cref="BindableObject"/> object
/// </summary>
/// <param name="bindable">Bindable object that is source of event to Attach</param>
/// <exception cref="ArgumentException">Thrown if no matching event exists on
/// <see cref="BindableObject"/></exception>
protected override void OnAttachedTo(BindableObject bindable)
{
base.OnAttachedTo(bindable);
Expand All @@ -136,6 +168,10 @@ protected override void OnAttachedTo(BindableObject bindable)
AddEventHandler(_eventInfo, AssociatedObject, OnEventRaised);
}

/// <summary>
/// Unsubscribes from the event on <paramref name="bindable"/>
/// </summary>
/// <param name="bindable"><see cref="BindableObject"/> that is source of event</param>
protected override void OnDetachingFrom(BindableObject bindable)
{
if (_handler != null)
Expand Down Expand Up @@ -167,6 +203,11 @@ private void AddEventHandler(EventInfo eventInfo, object item, Action<object, Ev
eventInfo.AddEventHandler(item, _handler);
}

/// <summary>
/// Method called when event is raised
/// </summary>
/// <param name="sender">Source of that raised the event</param>
/// <param name="eventArgs">Arguments of the raised event</param>
protected virtual void OnEventRaised(object sender, EventArgs eventArgs)
{
if (Command == null)
Expand Down

0 comments on commit 72f1a35

Please sign in to comment.