public Form1() { InitializeComponent(); InitializeData(); InitializeControl(); LoadSettings(null, null); MtGoxConfig = new Config(); mtgoxV0 = new MtGoxAPIV0(); }
public static void SaveToFile(Config config, string fileName) { using (MemoryStream memStream = new MemoryStream()) { DataContractSerializer serializer = new DataContractSerializer(typeof(Config)); serializer.WriteObject(memStream, config); // Encrypt the memory stream. byte[] encryptedData = Encryption.EncryptData(memStream.ToArray()); using (FileStream stream = new FileStream(fileName, FileMode.Create)) { stream.Write(encryptedData, 0, encryptedData.Length); } } }
public static Config LoadFromFile(string fileName) { Config config = new Config(); byte[] fileContents = File.ReadAllBytes(fileName); byte[] decryptedData = Encryption.DecryptData(fileContents); using (MemoryStream stream = new MemoryStream()) { stream.Write(decryptedData, 0, decryptedData.Length); stream.Position = 0; DataContractSerializer serializer = new DataContractSerializer(typeof(Config)); config = (Config)serializer.ReadObject(stream); } return config; }
private void showContent() { MtGoxConfig = new Config(); try { MtGoxConfig = ConfigHelper.LoadFromFile(this.configrFullPath); this.txtKey.Text = MtGoxConfig.Key; this.txtSecret.Text = MtGoxConfig.Secret; this.comboCurrency.SelectedItem = MtGoxConfig.Currency; } catch(Exception e) { } }