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