创建WP8试用应用
参考资料:
Windows Phone 7 开发 31 日谈——第23日:提供试用版应用程序
对资料总结下:
如何检查应用中的试用许可证:
在App.xaml.cs中添加下面两行
using Microsoft.Phone.Marketplace;
private static LicenseInformation _licenseInfo = new LicenseInformation();
使用_licenseInfo.IsTrial()方法,即读取LicenseInformation对象上的IsTrial属性,返回True时为试用版,否则为付费版
但是实际上在调试时,应用的真实许可信息只有在发布到商店后才能使用,所以再在App.xaml.cs里使用以下两段代码。使用后,在调试时将执行#if Debug与#else之间的代码,进行手动设置是否为试用版;在释放模式下时,将执行#else与#endif之间的代码,即读取LicenseInformation对象上的IsTrial属性来设置是否试用版。
private static bool _isTrial = true;
public bool IsTrial
{
get
{
return _isTrial;
}
}
/// <summary>
/// Check the current license information for this application
/// </summary>
private void CheckLicense()
{
// When debugging, we want to simulate a trial mode experience. The following conditional allows us to set the _isTrial
// property to simulate trial mode being on or off.
#if DEBUG
string message = "This sample demonstrates the implementation of a trial mode in an application." +
"Press 'OK' to simulate trial mode. Press 'Cancel' to run the application in normal mode.";
if (MessageBox.Show(message, "Debug Trial",
MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
_isTrial = true;
}
else
{
_isTrial = false;
}
#else
_isTrial = _licenseInfo.IsTrial();
#endif
}
在应用开始或恢复时都需要检查应用的许可证:
即在App.xaml.cs中的Application_Launching和Application_Activated事件中添加试用版的判断方法CheckLicense()
使用当前应用的许可证信息:
由于在App.xaml.cs里设置了IsTrial属性来读取许可证属性,因此我们可以通过使用(Application.Current as App).IsTrial属性来直接获取应用的许可证信息,避免重复使用IsTrial()方法,该方法一次典型调用耗时60毫秒或更多。
创建WP8试用应用的更多相关文章
- 学习 WebService 第五步:在Local创建测试用WebService(WSDL)
[准备] Eclipse+Tomcat7(Tomcat端口修改为不冲突的值) axis2 1.7.7 jar包(没有来这里下载:http://www.apache.org/dyn/closer.lua ...
- ASP.NET Core 中文文档 第二章 指南(1)用 Visual Studio Code 在 macOS 上创建首个 ASP.NET Core 应用程序
原文:Your First ASP.NET Core Application on a Mac Using Visual Studio Code 作者:Daniel Roth.Steve Smith ...
- WP7/WP8/WP8.1设置存储的区别
最近做的一个软件,由于最初是针对WP7的,现在在只能创建WP8.1的visual studio 2013上转换为了WP8的. 由于要保存字体大小.背景颜色.JSON三个数据,一直使用的是WP7下的存储 ...
- Cordova WP8 平台安装部署
原文:Cordova WP8 平台安装部署 Cordova是一个开放源码移动开发框架. 它允许您使用标准的 web 技术如 HTML5. CSS3 和 JavaScript 进行跨平台开发,避免每个移 ...
- 使用 Azure CLI 创建 Windows 虚拟机
Azure CLI 用于从命令行或脚本创建和管理 Azure 资源. 本指南详细介绍如何使用 Azure CLI 部署运行 Windows Server 2016 的虚拟机. 部署完成后,我们连接到服 ...
- 使用 Azure 门户创建 Windows 虚拟机
可以通过 Azure 门户创建 Azure 虚拟机. 此方法提供一个基于浏览器的用户界面,用于创建和配置虚拟机和所有相关的资源. 本快速入门介绍了如何创建虚拟机并在 VM 上安装 webserver. ...
- 使用 PowerShell 创建 Linux 虚拟机
Azure PowerShell 模块用于从 PowerShell 命令行或脚本创建和管理 Azure 资源. 本指南详细介绍了如何使用 Azure PowerShell 模块部署运行 Ubuntu ...
- 使用 Azure 门户创建 Linux 虚拟机
可以通过 Azure 门户创建 Azure 虚拟机. 此方法提供一个基于浏览器的用户界面,用于创建和配置虚拟机和所有相关的资源. 本快速入门介绍了如何创建虚拟机并在 VM 上安装 webserver. ...
- 使用 Azure CLI 创建 Linux 虚拟机
Azure CLI 用于从命令行或脚本创建和管理 Azure 资源. 本指南详细介绍了如何使用 Azure CLI 部署运行 Ubuntu 服务器的虚拟机. 服务器部署以后,将创建 SSH 连接,并且 ...
随机推荐
- CMake学习笔记
C++开发者必备技能CMake 先简单介绍一下,CMake是一个跨平台的编译工具,它可以根据不用的平台,不同的编译环境,生成不同的MakeFile,从而控制编译的过程. 使用CMake的步骤: 1. ...
- SwipeMenuListView在ScrollView里上下滑动导致菜单不能显示完全的bug解决方法
这是因为上下滑动的时候,事件被ScrollView截获了,这时候应该禁止ScrollView截获上下滑动事件,解决方法如下 public class NoRollSwipeMenuListView e ...
- 项目vue2.0仿外卖APP(四)
组件拆分 先把项目搭建时生成的代码给清了吧 现在static目录下引入reset.css 接着在index.html引入,并且设置<meta> 有时候呢,为了让代码符合我们平时的编码习惯, ...
- java 写文本换行
import org.apache.commons.io.FileUtils; public static void main(String[] args) throws IOException { ...
- WCF调用
1.找到服务中的point终结点 2.添加服务地址就可以了
- mina中游戏客户端服务端数据交互流程
====================================================================================CLIENT encode ...
- jquery动态添加的html,第三方插件无法生效的情况
今天一个问题纠结了半天,问题如下图 问题大致就是如上,新增的内容死活点不起,插件没有生效,在一个装逼前端群里面问,给我的答案是叫我去了解事件委托,了解一下事件冒泡!! 好吧,我一上午加半个下午的时间 ...
- swift错误 Expressions are not allowed at the top level
``` ... earlier we said top-level code isn't allowed in most of your app's source files. The excepti ...
- "_OBJC_CLASS_$_CMMotionManager", referenced from:
好久没写随笔了,今日项目爆红.如下: 缺少系统库 CoreMotion.framework, 在Build Phases -> Link Binary With Libraries 中添加即可.
- extarea输入的换行在网页上正常显示
如图