/// <summary> /// Gets the exported settings. /// </summary> /// <returns>Settings which can be moved in between machines.</returns> public string ExportSettings() { // Clone the current object into a new one. ApplicationData applicationData = JObject.FromObject(this).ToObject <ApplicationData>(); // Unprotect the data before exporting. applicationData.relaySharedKeyBytes = DataProtection.Unprotect(applicationData.relaySharedKeyBytes); return(JsonConvert.SerializeObject(applicationData)); }
/// <summary> /// Imports the settings. /// </summary> /// <param name="serializedSettings">The serialized settings.</param> /// <returns>Application data.</returns> public static ApplicationData ImportSettings(string serializedSettings) { ApplicationData applicationData = JsonConvert.DeserializeObject <ApplicationData>(serializedSettings); // Encrypt the data with DPAPI. if (applicationData.EnableCredentialEncryption) { applicationData.relaySharedKeyBytes = DataProtection.Protect(applicationData.relaySharedKeyBytes); } return(applicationData); }