private void CreateConfiguration()
        {
            var publicSettings  = new DscPublicSettings();
            var privateSettings = new DscPrivateSettings();

            publicSettings.ProtocolVersion = CurrentProtocolVersion;

            if (!string.IsNullOrEmpty(this.ConfigurationArchive))
            {
                ConfigurationUris configurationUris = UploadConfigurationDataToBlob();

                publicSettings.SasToken              = configurationUris.SasToken;
                publicSettings.ModulesUrl            = configurationUris.ModulesUrl;
                publicSettings.ConfigurationFunction = string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}\\{1}",
                    Path.GetFileNameWithoutExtension(this.ConfigurationArchive),
                    this.ConfigurationName);
                Tuple <DscPublicSettings.Property[], Hashtable> settings =
                    DscSettingsSerializer.SeparatePrivateItems(this.ConfigurationArgument);
                publicSettings.Properties = settings.Item1;
                privateSettings.Items     = settings.Item2;

                privateSettings.DataBlobUri = configurationUris.DataBlobUri;
            }

            //
            // Define the public and private property bags that will be passed to the extension.
            //
            this.PublicConfiguration = DscSettingsSerializer.SerializePublicSettings(publicSettings);
            //
            // PrivateConfuguration contains sensitive data in a plain text.
            //
            this.PrivateConfiguration = DscSettingsSerializer.SerializePrivateSettings(privateSettings);
        }
示例#2
0
        /// <summary>
        /// Helper function for tests.
        /// </summary>
        /// <param name="configurationArguments"></param>
        /// <param name="privateSettings"></param>
        /// <returns></returns>
        private static DscPublicSettings GetPublicPrivateAfterDeseriazlization(
            Hashtable configurationArguments,
            out DscPrivateSettings privateSettings)
        {
            Tuple <DscPublicSettings.Property[], Hashtable> separatedSettings =
                DscSettingsSerializer.SeparatePrivateItems(configurationArguments);
            DscPublicSettings publicSettings = new DscPublicSettings();

            privateSettings           = new DscPrivateSettings();
            publicSettings.Properties = separatedSettings.Item1;
            privateSettings.Items     = separatedSettings.Item2;

            string serializedPublic  = DscSettingsSerializer.SerializePublicSettings(publicSettings);
            string serializedPrivate = DscSettingsSerializer.SerializePrivateSettings(privateSettings);

            publicSettings  = DscSettingsSerializer.DeserializePublicSettings(serializedPublic);
            privateSettings = DeserializePrivateSettings(serializedPrivate);
            return(publicSettings);
        }