private void WriteSystemSettingsData() { if (file == null) { return; } SystemSettingsData.Root data = new SystemSettingsData.Root(); data.Halo1 = CopyFromGenericPropertyPage((GenericPropertyPage)H1Page.SelectedObject); data.Halo2 = CopyFromGenericPropertyPage((GenericPropertyPage)H2Page.SelectedObject); data.Halo3 = CopyFromGenericPropertyPage((GenericPropertyPage)H3Page.SelectedObject); data.Halo3ODST = CopyFromGenericPropertyPage((GenericPropertyPage)ODSTPage.SelectedObject); data.HaloReach = CopyFromGenericPropertyPage((GenericPropertyPage)ReachPage.SelectedObject); data.Halo4 = CopyFromGenericPropertyPage((GenericPropertyPage)H4Page.SelectedObject); data.Halo2A = CopyFromGenericPropertyPage((GenericPropertyPage)H2APage.SelectedObject); string json = JsonConvert.SerializeObject(data); byte[] buffer = Compress(json); using (var writer = file.OpenWrite()) { writer.SetLength(0); writer.Flush(); writer.Write(buffer, 0, buffer.Length); writer.Flush(); writer.Close(); } }
private void ReadSystemSettingsData() { if (file == null) { return; } file.Refresh(); byte[] buffer = new byte[file.Length]; using (var reader = file.OpenRead()) { reader.Read(buffer, 0, buffer.Length); reader.Close(); } string json = Decompress(buffer); SystemSettingsData.Root data = JsonConvert.DeserializeObject <SystemSettingsData.Root>(json); H1Page.SelectedObject = CopyToGenericPropertyPage(data.Halo1); H2Page.SelectedObject = CopyToGenericPropertyPage(data.Halo2); H3Page.SelectedObject = CopyToGenericPropertyPage(data.Halo3); ODSTPage.SelectedObject = CopyToGenericPropertyPage(data.Halo3ODST); ReachPage.SelectedObject = CopyToGenericPropertyPage(data.HaloReach); H4Page.SelectedObject = CopyToGenericPropertyPage(data.Halo4); H2APage.SelectedObject = CopyToGenericPropertyPage(data.Halo2A); }