Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Jul 13, 2017
1 parent f4be385 commit eee0867
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 52 deletions.
26 changes: 26 additions & 0 deletions docs/Architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

## Architecture

I get a lot of questions about architecture and how to unit tests plugins. So here are some things to be aware of for any plugin that I publish.

### What's with this .Current Global Variable? Why can't I use $FAVORITE_IOC_LIBARY
You totally can! Every plugin I create is based on an interface. The static singleton just gives you a super simple way of gaining access to the platform implementation. Realize that the implementation of the plugin lives in your iOS, Android, Windows, etc. Thies means you will need to register it there by instantiating a `Cross___Implementation` from the platform specific projects.

If you are using a ViewModel/IOC approach your code may look like:

```csharp
public MyViewModel()
{
readonly IPLUGIN plugin;
public MyViewModel(IPLUGIN plugin)
{
this.plugin = plugin;
}
}
```

### What About Unit Testing?
To learn about unit testing strategies be sure to read my blog: [Unit Testing Plugins for Xamarin](http://motzcod.es/post/159267241302/unit-testing-plugins-for-xamarin)


<= Back to [Table of Contents](README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task<bool> WasItemPurchased(string productId)
}
```

Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](8-SecuringPurchases.md) documentation.
Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](SecuringPurchases.md) documentation.


<= Back to [Table of Contents](README.md)
File renamed without changes.
39 changes: 0 additions & 39 deletions docs/1-GettingStarted.md → docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,44 +118,5 @@ protected override void OnActivityResult(int requestCode, Result resultCode, Int
}
```

## Architecture

### What's with this .Current Global Variable? Why can't I use $FAVORITE_IOC_LIBARY
You totally can! Every plugin I create is based on an interface. The static singleton just gives you a super simple way of gaining access to the platform implementation. If you are looking to use Depenency Injector or Inversion of Control (IoC) you will need to gain access to a reference of `IInAppBilling`.

This is what your code may look like when using this approach:

```csharp
public MyViewModel()
{
readonly IInAppBilling billing;
public MyViewModel(IInAppBilling billing)
{
this.billing = billing;
}

public async Task<bool> MakePurchase()
{
try
{
var connected = await billing.ConnectAsync();
if(!connected)
return false;

//make additional billing calls
}
finally
{
await billing.DisconnectAsync();
}
}
}
```

Remember that the implementation of the plugin lives in the platform specific applications, which means you will need to register .Current (or instantiate your own CrossInAppBillingImplementation) in your IoC container as the implementation of `IInAppBilling` on each platform. This registration must happen from your application binary, not from your portable/netstandard class library.

### What About Unit Testing?
To learn about unit testing strategies be sure to read my blog: [Unit Testing Plugins for Xamarin](http://motzcod.es/post/159267241302/unit-testing-plugins-for-xamarin)


<= Back to [Table of Contents](README.md)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public async Task<bool> PurchaseItem(string productId, string payload)
}
```

Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](8-SecuringPurchases.md) documentation.
Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](SecuringPurchases.md) documentation.


<= Back to [Table of Contents](README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task<bool> PurchaseItem(string productId, string payload)
}
```

Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](8-SecuringPurchases.md) documentation.
Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](SecuringPurchases.md) documentation.


<= Back to [Table of Contents](README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task<bool> PurchaseItem(string productId, string payload)
}
```

Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](8-SecuringPurchases.md) documentation.
Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](SecuringPurchases.md) documentation.


<= Back to [Table of Contents](README.md)
19 changes: 10 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
Here you will find detailed documentation on setting up and using the In-App Billing Plugin for Xamarin and Windows

### Table of Contents
* [Getting Started](1-GettingStarted.md)
* [Handling Exceptions](2-HandlingExceptions.md)
* [Get Product Details](3-GetProductDetails.md)
* [Purchase Non-Consumable](4-PurchaseNonConsumable.md)
* [Purchase & Consume Consumable](5-PurchaseConsumable.md)
* [Purchase Subscription](6-PurchaseSubscription.md)
* [Check & Restore Purchases](7-CheckAndRestorePurchases.md)
* [Securing Purchases](8-SecuringPurchases.md)
* [Testing & Troubleshooting](9-TestingAndTroubleshooting.md)
* [Getting Started](GettingStarted.md)
* [Handling Exceptions](HandlingExceptions.md)
* [Get Product Details](GetProductDetails.md)
* [Purchase Non-Consumable](PurchaseNonConsumable.md)
* [Purchase & Consume Consumable](PurchaseConsumable.md)
* [Purchase Subscription](PurchaseSubscription.md)
* [Check & Restore Purchases](CheckAndRestorePurchases.md)
* [Securing Purchases](SecuringPurchases.md)
* [Testing & Troubleshooting](TestingAndTroubleshooting.md)
* [Architecture](Architecture.md)
File renamed without changes.
File renamed without changes.

0 comments on commit eee0867

Please sign in to comment.