Esempio n. 1
0
        public void ReadPlatformData(Action<PlatformList, Exception> callback)
        {
            Exception exception = null;
            try
            {
                string uri = "GamesXML/Platforms.xml";
                StreamResourceInfo SRI = Application.GetResourceStream(new Uri(uri, System.UriKind.Relative));

                XmlSerializer serializer = new XmlSerializer(typeof(PlatformList));
                FoundPlatforms = (PlatformList)serializer.Deserialize(SRI.Stream);
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            if (callback != null)
            {
                callback(FoundPlatforms, exception);
            }
        }
Esempio n. 2
0
 private static void SavePlatformData(PlatformList platformList, Exception exception)
 {
     if (exception != null)
     {
         // catch exception here
     }
     else
     {
         if (platformList.Platforms.Count > 0)
         {
             using (GameDataContext context = new GameDataContext(Constants.DBConnectionString))
             {
                 foreach (PlatformData item in platformList.Platforms)
                 {
                     context.Platform.InsertOnSubmit(item);
                 }
                 context.SubmitChanges();
             }
         }
         else
         {
             // have no data
         }
     }
 }