using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
//<
Namespaces >
using Windows.Services.Store; //Store Add-ons Packages to buy
using System.Threading.Tasks;
//</
Namespaces >
namespace Check_InApp_Produkct_Status
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
#region Buttons
//------------------<
region: Buttons >------------------
private void
btnGet_Addins_Click(object sender, RoutedEventArgs e)
{
get_Store_LicenseInfo();
}
private void
btnCheck_First_Addon_Click(object sender, RoutedEventArgs e)
{
check_First_AddOn_Package();
}
//------------------</
region: Buttons >------------------
#endregion /Buttons
#region Windows-Store
//------------------<
region: Windows-Store >------------------
private StoreContext context = null;
private StoreAppLicense appLicense = null;
public async Task<bool> get_Store_LicenseInfo()
{
//-------------<
get_Store_LicenseInfo()-------------
if (context == null)
{
context = StoreContext.GetDefault(); //UWP App
}
workingProgressRing.IsActive = true;
//<
get Store Data >
appLicense = await context.GetAppLicenseAsync();
//</
get Store Data >
workingProgressRing.IsActive = false;
if (appLicense == null)
{
tbxStatus.Text = "An error occurred while retrieving the license.";
return false ;
}
else
{
//--< show License Infos >--
tbxStatus.Text = "APP-License" + Environment.NewLine + "SkuStoreId=" + appLicense.SkuStoreId ;
tbxStatus.Text += Environment.NewLine + "TrialUniqueId=" + Convert.ToString(appLicense.TrialUniqueId);
tbxStatus.Text += Environment.NewLine + "IsActive=" + Convert.ToString(appLicense.IsActive );
tbxStatus.Text += Environment.NewLine + "IsTrial=" + Convert.ToString( appLicense.IsTrial);
tbxStatus.Text += Environment.NewLine + Environment.NewLine + "AddOnLicenses=" + Convert.ToString(appLicense.AddOnLicenses.Count);
//--</ show License Infos >--
}
//
Access the add on licenses for add-ons for this app.
tbxStatus.Text += Environment.NewLine + "< addOn-Licenses>" + Environment.NewLine;
foreach (KeyValuePair<string, StoreLicense> item in
appLicense.AddOnLicenses)
{
StoreLicense addOnLicense =
item.Value;
//--< addon Purchase Infos
>--
tbxStatus.Text = "addOn-License" + Environment.NewLine + "IsActive=" +
addOnLicense.IsActive;
tbxStatus.Text += Environment.NewLine + "SkuStoreId=" + Convert.ToString(addOnLicense.SkuStoreId
);
tbxStatus.Text += Environment.NewLine + "InAppOfferToken=" + Convert.ToString(addOnLicense.InAppOfferToken
);
tbxStatus.Text += Environment.NewLine + "ExpirationDate=" + Convert.ToString(addOnLicense.ExpirationDate
);
//--</ addon Purchase Infos >--
}
tbxStatus.Text += "</ addOn-Licenses>" + Environment.NewLine;
return true;
//-------------</
get_Store_LicenseInfo()-------------
}
public async void check_First_AddOn_Package()
{
//-------------<
check_First_AddOn_Package()-------------
if (context == null)
{
await get_Store_LicenseInfo();
}
//<
check >
//</
check >
if (appLicense == null)
{
tbxStatus.Text = "appLicense is null.";
return;
}
else
{
tbxStatus.Text = "AddOnLicenses.Count=" + Convert.ToString(appLicense.AddOnLicenses.Count);
//--</ show License Infos >--
}
tbxStatus.Text += Environment.NewLine + "< addOn-License 1 >" + Environment.NewLine;
foreach (KeyValuePair<string, StoreLicense> item in
appLicense.AddOnLicenses)
{
StoreLicense addOnLicense =
item.Value;
//--< addon Purchase Infos
>--
tbxStatus.Text = "addOn-License" + Environment.NewLine + "IsActive=" +
addOnLicense.IsActive;
break;
//--</ addon Purchase Infos >--
}
tbxStatus.Text += "</ addOn-License 1 >" + Environment.NewLine;
return ;
//-------------</
check_First_AddOn_Package()-------------
}
//------------------</region:
Windows-Store >------------------
#endregion /Windows-Store
}
}
|