Вопрос

I'm porting my game "Bustin' Jieber" on Windows Phone to Windows 8, and I have to do a isolated storage-like system to hold the settings, records and the money. I'm using this on windows phone:

IsolatedStorageSettings iosystem = IsolatedStorageSetting.ApplicationSettings;

and for example the money system;

iosystem["bjc"] = (int.Parse(iosystem["bjc"].ToString()) + (points * int.Parse(iosystem["pointduplication"].ToString())));

How can I implement this into my code? Please give me a usable code (with namespaces or so) ! Thanks! also, app is c#...

Это было полезно?

Решение

You can use ApplicationData.Current.LocalSettings;

Sample Code:

Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

// Create a simple setting

localSettings.Values["exampleSetting"] = "Hello Windows";

// Read data from a simple setting

Object value = localSettings.Values["exampleSetting"];

if (value == null)
{
    // No data
}
else
{
    // Access data in value
}

// Delete a simple setting

localSettings.Values.Remove("exampleSetting");

& here is relevant post from MSDN

Apart from this you can try this from CodePlex [I didn't tried this before]

Другие советы

By said by kumar, you can use ApplicationData stuff, but let me show you an easier version based on kumar's answer:

Windows.Foundation.Collections.IPropertySet setting = Windows.Storage.ApplicationData.Current.LocalSettings.Values;

and just replace localsettings.Values (on kumar's answer) to setting. Good luck people :)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top