コード例 #1
0
        /// <summary>
        /// <para>Load the configured protection mechanism for the section. This is the <see cref="KeyAlgorithmPairStorageProviderData"/> to load the <see cref="KeyAlgorithmPair"/>.</para>
        /// </summary>
        /// <param name="sectionName">
        /// <para>The name of the section to encrypt.</para>
        /// </param>
        /// <param name="context">
        /// <para>A <see cref="ConfigurationContext"/> object.</para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="context"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="ConfigurationException">
        /// <para>An error occured in configuration.</para>
        /// </exception>
        public void Load(ConfigurationContext context, string sectionName)
        {
            ArgumentValidation.CheckForNullReference(context, "context");
            ArgumentValidation.CheckForNullReference(sectionName, "sectionName");
            ArgumentValidation.CheckForEmptyString(sectionName, "sectionName");

            ConfigurationSettings    settings = context.GetMetaConfiguration();
            ConfigurationSectionData data     = settings.ConfigurationSections[sectionName];

            if (null == data)
            {
                InvalidSectionExceptionBuilder builder = new InvalidSectionExceptionBuilder(sectionName, context.ConfigurationFile);
                throw builder.ThrowException();
            }

            if ((null == settings.KeyAlgorithmPairStorageProviderData) && (data.Encrypt))
            {
                throw new ConfigurationException(SR.ExceptionNoKeyAlgorithmStorageProvider);
            }

            if (data.Encrypt)
            {
                SetDataToBeEncrypted(context);
            }
        }
コード例 #2
0
 private void ValidateSection(string sectionName)
 {
     if (!IsValidSection(sectionName))
     {
         InvalidSectionExceptionBuilder builder = new InvalidSectionExceptionBuilder(sectionName, this.currentConfigFileName);
         throw builder.ThrowException();
     }
 }
コード例 #3
0
        /// <summary>
        /// <para>Retrieves the <see cref="TransformerData"/> for the section.</para>
        /// </summary>
        /// <param name="sectionName">
        /// <para>The name of the section to get the <see cref="TransformerData"/></para>
        /// </param>
        /// <returns>
        /// <para>The <see cref="TransformerData"/> for the section.</para>
        /// </returns>
        public virtual TransformerData GetTransformerProviderData(string sectionName)
        {
            ConfigurationSettings settings = GetConfigurationSettings();

            ConfigurationSectionData configurationSectionData = settings.ConfigurationSections[sectionName];

            if (configurationSectionData == null)
            {
                InvalidSectionExceptionBuilder builder = new InvalidSectionExceptionBuilder(sectionName, ConfigurationContext.ConfigurationFile);
                throw builder.ThrowException();
            }

            return(configurationSectionData.Transformer);
        }
コード例 #4
0
        /// <summary>
        /// <para>Retrieves the <see cref="TransformerData"/> for the section.</para>
        /// </summary>
        /// <param name="sectionName">
        /// <para>The name of the section to get the <see cref="TransformerData"/></para>
        /// </param>
        /// <returns>
        /// <para>The <see cref="TransformerData"/> for the section.</para>
        /// </returns>
        public virtual TransformerData GetTransformerProviderData(string sectionName)
        {
            ConfigurationSettings settings = GetConfigurationSettings();

            ConfigurationSectionData configurationSectionData = settings.ConfigurationSections[sectionName];
            if (configurationSectionData == null)
            {
                InvalidSectionExceptionBuilder builder = new InvalidSectionExceptionBuilder(sectionName, ConfigurationContext.ConfigurationFile);
                throw builder.ThrowException();
            }

            return configurationSectionData.Transformer;
        }
コード例 #5
0
        /// <summary>
        /// <para>Load the configured protection mechanism for the section. This is the <see cref="KeyAlgorithmPairStorageProviderData"/> to load the <see cref="KeyAlgorithmPair"/>.</para>
        /// </summary>
        /// <param name="sectionName">
        /// <para>The name of the section to encrypt.</para>
        /// </param>
        /// <param name="context">
        /// <para>A <see cref="ConfigurationContext"/> object.</para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="context"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="ConfigurationException">
        /// <para>An error occured in configuration.</para>
        /// </exception>
        public void Load(ConfigurationContext context, string sectionName)
        {
            ArgumentValidation.CheckForNullReference(context, "context");
            ArgumentValidation.CheckForNullReference(sectionName, "sectionName");
            ArgumentValidation.CheckForEmptyString(sectionName, "sectionName");

            ConfigurationSettings settings = context.GetMetaConfiguration();
            ConfigurationSectionData data = settings.ConfigurationSections[sectionName];
            if (null == data)
            {
                InvalidSectionExceptionBuilder builder = new InvalidSectionExceptionBuilder(sectionName, context.ConfigurationFile);
                throw builder.ThrowException();
            }

            if ((null == settings.KeyAlgorithmPairStorageProviderData) && (data.Encrypt))
            {
                throw new ConfigurationException(SR.ExceptionNoKeyAlgorithmStorageProvider);
            }

            if (data.Encrypt)
            {
                SetDataToBeEncrypted(context);
            }
        }
コード例 #6
0
 private void ValidateSection(string sectionName)
 {
     if (!IsValidSection(sectionName))
     {
         InvalidSectionExceptionBuilder builder = new InvalidSectionExceptionBuilder(sectionName, this.currentConfigFileName);
         throw builder.ThrowException();
     }
 }