我尝试为Metro应用实施应用内购买。我在这里按照教程。
C#代码是
function AppInit()
{
// some app initialization functions
// Get the license info
// The next line is commented out for testing.
// licenseInformation = CurrentApp.LicenseInformation;
// The next line is commented out for production/release.
licenseInformation = CurrentAppSimulator.LicenseInformation;
// other app initialization functions
}
但是,C#中没有function
个关键字。这是错误的?如果是这样,假设正确的代码是什么?
答案 0 :(得分:2)
该教程似乎错误地显示了代码的javascript版本。我在App类中有许可证初始化代码,在OnLaunched()函数中:
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
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)
{
#if DEBUG
licenseInformation = CurrentAppSimulator.LicenseInformation;
#else
licenseInformation = CurrentApp.LicenseInformation;
#endif
// other init here...
}
}