private void CreateConfiguration() { var publicSettings = new DscExtensionPublicSettings(); var privateSettings = new DscExtensionPrivateSettings(); if (!string.IsNullOrEmpty(ConfigurationArchive)) { ConfigurationUris configurationUris = UploadConfigurationDataToBlob(); publicSettings.SasToken = configurationUris.SasToken; publicSettings.ModulesUrl = configurationUris.ModulesUrl; Hashtable privacySetting = new Hashtable(); privacySetting.Add("DataCollection",DataCollection); publicSettings.Privacy = privacySetting; publicSettings.ConfigurationFunction = string.Format( CultureInfo.InvariantCulture, "{0}\\{1}", Path.GetFileNameWithoutExtension(ConfigurationArchive), ConfigurationName); Tuple<DscExtensionPublicSettings.Property[], Hashtable> settings = DscExtensionSettingsSerializer.SeparatePrivateItems(ConfigurationArgument); publicSettings.Properties = settings.Item1; privateSettings.Items = settings.Item2; privateSettings.DataBlobUri = configurationUris.DataBlobUri; if (!string.IsNullOrEmpty(WmfVersion)) { publicSettings.WmfVersion = WmfVersion; } } // // Define the public and private property bags that will be passed to the extension. // PublicConfiguration = DscExtensionSettingsSerializer.SerializePublicSettings(publicSettings); // // PrivateConfuguration contains sensitive data in a plain text. // PrivateConfiguration = DscExtensionSettingsSerializer.SerializePrivateSettings(privateSettings); }
/// <summary> /// Helper function for tests. /// </summary> /// <param name="configurationArguments"></param> /// <param name="privateSettings"></param> /// <returns></returns> private static DscExtensionPublicSettings GetPublicPrivateAfterDeseriazlization( Hashtable configurationArguments, out DscExtensionPrivateSettings privateSettings) { Tuple<DscExtensionPublicSettings.Property[], Hashtable> separatedSettings = DscExtensionSettingsSerializer.SeparatePrivateItems(configurationArguments); DscExtensionPublicSettings extensionPublicSettings = new DscExtensionPublicSettings(); privateSettings = new DscExtensionPrivateSettings(); extensionPublicSettings.Properties = separatedSettings.Item1; privateSettings.Items = separatedSettings.Item2; string serializedPublic = DscExtensionSettingsSerializer.SerializePublicSettings(extensionPublicSettings); string serializedPrivate = DscExtensionSettingsSerializer.SerializePrivateSettings(privateSettings); extensionPublicSettings = DscExtensionSettingsSerializer.DeserializePublicSettings(serializedPublic); privateSettings = DeserializePrivateSettings(serializedPrivate); return extensionPublicSettings; }
/// <summary> /// Serialize DscPrivateSettings to string. /// </summary> /// <param name="privateSettings"></param> /// <returns></returns> public static string SerializePrivateSettings(DscExtensionPrivateSettings privateSettings) { return JsonConvert.SerializeObject(privateSettings); }
/// <summary> /// Serialize DscPrivateSettings to string. /// </summary> /// <param name="privateSettings"></param> /// <returns></returns> public static string SerializePrivateSettings(DscExtensionPrivateSettings privateSettings) { return(JsonConvert.SerializeObject(privateSettings)); }