This repository has been archived by the owner on Nov 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Added basic Getting Started Instructions for UWP, Android and NETCor…
…e. As well as some pointers about using Settings Properties. -Added Test-NETCore for testing the NETCore Implementation. -Fixed NETCore Settings Container Creation. -Console PromptUserAsync is now an a numbered prompt.
- Loading branch information
1 parent
642a259
commit b176089
Showing
13 changed files
with
232 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using PlatformBindings; | ||
using PlatformBindings.ConsoleTools; | ||
|
||
namespace Test_NETCore | ||
{ | ||
internal class Program | ||
{ | ||
public static NETCoreServices Services { get; private set; } | ||
|
||
private static void Main(string[] args) | ||
{ | ||
Services = new NETCoreServices(); | ||
ConsoleHelpers.SystemWriteLine("Hello World!"); | ||
Init(); | ||
ConsoleHelpers.PreventClose(); | ||
} | ||
|
||
private static async void Init() | ||
{ | ||
var result = await AppServices.UI.PromptUserAsync("Hello", "This is an Example", "Opt1", "Opt2"); | ||
ConsoleHelpers.SystemWriteLine("Result: " + result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\NETCore\PlatformBindings-NETCore.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
boop | ||
# Getting Started with the Platform Bindings Framework | ||
|
||
## Initialisation | ||
|
||
In order to be able to use this Framework, you must first Initalise the AppServices Class at your Application's Startup. This must be in your App's Project, as it requires the Project's Platform. | ||
|
||
To see how to Initialise your Platform, see: | ||
* [UWP](Platform/UWP/UWPRemarks.md#Getting-Started) | ||
* [Android](Platform/Android/AndroidRemarks.md#Getting-Started) | ||
* [Xamarin Forms](Platform/XamarinForms/XamarinFormsRemarks.md) | ||
* [NETCore](Platform/NETCore/NETCoreRemarks.md#Getting-Started) | ||
|
||
### Things to be aware of | ||
|
||
Due to AppServices being Initialised after Static Construction, be wary of `AppSettings`, and other Settings Classes that try to Access AppServices.IO.LocalSettings or AppServices.IO.RoamingSettings. These will cause and exception if that is the case. | ||
|
||
Instead use a static Property with a Getter to construct the Property, only when needed. This should also be better for memory usage, as it allows the Garbage Collector to clean up the Object when finished manipulation. As well as update values when they change from other sources. | ||
|
||
**Use:** | ||
```c# | ||
public static AppSetting<bool> ExampleToggleSetting => new AppSetting<bool>(); | ||
``` | ||
|
||
**Instead of:** | ||
```C# | ||
public static AppSetting<bool> ExampleToggleSetting = new AppSetting<bool>(); | ||
``` | ||
|
||
While the latter might work, if the Static Property is constructed before AppServices, it will cause an Exception. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# PlatformBindings-Android Remarks | ||
|
||
## Getting Started | ||
|
||
To use the Android Platform Library, you must first have the `PlatformBindings-Android` Package installed. | ||
|
||
### Activity Inheritance | ||
|
||
In order to use all of PlatformBindings-Android's Functionality, you must have an Activity that is compatible with the ActivityHandler, this can be achieved multiple ways for different Reasons. | ||
|
||
You can Inherit your Activity from `PlatformBindingActivity`, this is a Super Class of `Activity`, where Overriden methods handoff to the ActivityHandler. | ||
|
||
You can Inherit your Activity from `PlatformBindingCompatActivity`, this is a Super Class of `Android.Support.V7.App.AppCompatActivity`, where Overriden methods handoff to the ActivityHandler. | ||
|
||
If you already have your own Activity Super Class, or you inherit from another library, such as MVVMCross, then you can Override the Required Methods yourself to create your own PlatformBinding Supported Activity. | ||
|
||
See [here](https://github.com/WilliamABradley/PlatformBindingsFramework/blob/master/Android/Activities/PlatformBindingActivity.cs) for an example Implementation of an ActivityHandler handoff, Activtiy Super Class. | ||
|
||
### Initialisation | ||
|
||
In your First Activity, Create the AppServices Class Object either in the Constructor. It **MUST** be Constructed before `base.OnCreate(Bundle)` is called, as that is when Activity Registration begins. | ||
|
||
```C# | ||
public class MainActivity : PlatformBindingActivity | ||
{ | ||
public static AndroidAppServices Services { get; private set; } = new AndroidAppServices(true); | ||
|
||
|
||
protected override void OnCreate(Bundle bundle) | ||
{ | ||
// Build App Services before calling base, to allow binding. | ||
base.OnCreate(bundle); | ||
StartActivity(typeof(Shell)); | ||
Finish(); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# PlatformBindings-NETCore Remarks | ||
|
||
## Getting Started | ||
|
||
To use the NETCore Platform Library, you must first have the `PlatformBindings-NETCore` Package installed. Then Create the AppServices Class Object in your Applications `static void Main(string[] args)` Method. | ||
This can't be created Statically, as any Calls in the Main Method will come before Static Initialisation. | ||
|
||
```C# | ||
internal class Program | ||
{ | ||
public static NETCoreServices Services { get; private set; } | ||
|
||
private static void Main(string[] args) | ||
{ | ||
Services = new NETCoreServices(); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# PlatformBindings-UWP Remarks | ||
|
||
## Getting Started | ||
|
||
To use the UWP Platform Library, you must first have the `PlatformBindings-UWP` Package installed. Then in your Application Class (App.xaml.cs), Create the AppServices Class Object either in the Constructor or Statically. | ||
|
||
```C# | ||
public static UWPAppServices Services = new UWPAppServices(true); | ||
``` | ||
|
||
Due to UWP's Design, the Dispatcher isn't available yet, so you will need to attach the Dispatcher when it becomes available, such as in the `OnLaunched` Method. Make sure you don't call any AppServices.UI methods before Attaching the Dispatcher. | ||
|
||
After Attaching the Dispatcher is the best time to load any PlatformBindings extensions. Such as PlatformBindings-SMB. | ||
|
||
```C# | ||
/// <summary> | ||
/// Invoked when the application is launched normally by the end user. Other entry points | ||
/// will be used such as when the application is launched to open a specific file. | ||
/// </summary> | ||
/// <param name="e">Details about the launch request and process.</param> | ||
protected override void OnLaunched(LaunchActivatedEventArgs e) | ||
{ | ||
Frame rootFrame = Window.Current.Content as Frame; | ||
|
||
// Do not repeat app initialization when the Window already has content, | ||
// just ensure that the window is active | ||
if (rootFrame == null) | ||
{ | ||
// Create a Frame to act as the navigation context and navigate to the first page | ||
rootFrame = new Frame(); | ||
Services.AttachDispatcher(rootFrame.Dispatcher); | ||
Tests.Preparation.Prepare(); | ||
|
||
rootFrame.NavigationFailed += OnNavigationFailed; | ||
|
||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) | ||
{ | ||
//TODO: Load state from previously suspended application | ||
} | ||
|
||
// Place the frame in the current Window | ||
Window.Current.Content = rootFrame; | ||
} | ||
|
||
if (e.PrelaunchActivated == false) | ||
{ | ||
if (rootFrame.Content == null) | ||
{ | ||
// When the navigation stack isn't restored navigate to the first page, | ||
// configuring the new page by passing required information as a navigation | ||
// parameter | ||
rootFrame.Navigate(typeof(MainPage), e.Arguments); | ||
} | ||
// Ensure the current window is active | ||
Window.Current.Activate(); | ||
} | ||
} | ||
``` |