Exemplo n.º 1
0
        private void LoadData()
        {
            EventProcessor.Instance.crewLaunches = null;
            EventProcessor.Instance.launches     = null;
            String savePath = SAVE_BASE_FOLDER + Utils.userName + "/";

            if (File.Exists(savePath + "statistic.json"))
            {
                using (StreamReader sr = new StreamReader(File.Open(savePath + "statistic.json", FileMode.Open), Encoding.UTF8))
                {
                    try
                    {
                        string json = sr.ReadToEnd();
                        if (json.Trim().Length > 2)
                        {
                            DataHolder dataHolder = (DataHolder)MyJsonUtil.JsonToObject <DataHolder>(json);
                            EventProcessor.Instance.crewLaunches = dataHolder.crewLaunches;
                            EventProcessor.Instance.launches     = dataHolder.launches;
                            useNativeGui = dataHolder.useNativeGui;
                        }
                        else
                        {
                            EventProcessor.Instance.crewLaunches = new List <LaunchCrewEvent>();
                            EventProcessor.Instance.launches     = new List <LaunchEvent>();
                        }
                    }
                    catch
                    {
                        EventProcessor.Instance.crewLaunches = new List <LaunchCrewEvent>();
                        EventProcessor.Instance.launches     = new List <LaunchEvent>();
                    }
                }
            }
            else
            {
                EventProcessor.Instance.crewLaunches = new List <LaunchCrewEvent>();
                EventProcessor.Instance.launches     = new List <LaunchEvent>();
            }
        }