private void Application_Launching(object sender, LaunchingEventArgs e)
{
//WP7Timer.Start();
//WP7Timer.Time("Start");
//provide invariant culture fo deserialization
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
//try to get the situation which was previously saved
City city = new City();
try
{
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isf.FileExists("City.dat"))
{
XmlSerializer ser = new XmlSerializer(typeof(City));
object obj = ser.Deserialize(isf.OpenFile("City.dat", System.IO.FileMode.Open)) as City;
if (obj != null && obj is City)
{
city = obj as City;
PhoneApplicationService.Current.State.Add("City", city);
}
}
}
}
catch (Exception)
{
//TODO - what to do with exception in the Launching event??
}
}