1

我尝试为 Metro 应用实施应用内购买。我在这里按照教程进行操作。

用于应用内购买的 C# 代码

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关键字。这是错误吗?如果是这样,正确的代码假设是什么?

4

1 回答 1

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...
        }
    }
于 2012-12-20T04:11:18.677 回答