2012-12-20 35 views
1

我試圖實現應用程序內購買的Metro應用。我在這裏按照教程。錯誤的應用程序內購買教程在微軟網站

C# code for in-app purchase

的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關鍵字。這是錯誤的?如果是這樣,那麼正確的代碼假設是什麼?

回答

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... 
     } 
    }