コード例 #1
0
        /// <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;
        }
コード例 #2
0
        /// <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));
        }