İngilizce dilinde oku

Aracılığıyla paylaş


ProtectedConfiguration Sınıf

Tanım

Geçerli uygulamanın yapılandırma dosyası için korumalı yapılandırma sağlayıcılarına erişim sağlar.

C#
public static class ProtectedConfiguration
Devralma
ProtectedConfiguration

Örnekler

Aşağıdaki örnekte, korumalı yapılandırma sağlayıcıları koleksiyonunu almak ve sağlayıcı adlarını, RSA sağlayıcı adını ve bölüm adlarını bulmak için sınıfının nasıl kullanılacağı ProtectedConfiguration gösterilmektedir.

C#
using System;
using System.Configuration;
using System.Collections;
using System.Security.Permissions;

namespace Samples.AspNet
{
  
    // Show how to use the ProtectedConfiguration.
    public sealed class UsingProtectedConfiguration
    {

        [PermissionSet(SecurityAction.Demand, Name="FullTrust")]    
     private static void GetProviders()
        {
            // Get the providers' collection.
            ProtectedConfigurationProviderCollection
                providers = ProtectedConfiguration.Providers;

            IEnumerator pEnum =
                providers.GetEnumerator();

            foreach (ProtectedConfigurationProvider provider in
                providers)
            {
                Console.WriteLine
                    ("Provider name: {0}",
                      provider.Name);
                Console.WriteLine
                         ("Provider description: {0}",
                          provider.Description);
            }
        }

       [PermissionSet(SecurityAction.Demand, Name="FullTrust")]    
    private static void GetProviderName()
        {
            // Get the current provider name.
            string dataProtectionProviderName =
               ProtectedConfiguration.DataProtectionProviderName;
            Console.WriteLine(
                "Data protection provider name: {0}",
                 dataProtectionProviderName);

            // Get the Rsa provider name.
            string rsaProviderName =
                ProtectedConfiguration.RsaProviderName;
            Console.WriteLine(
                "Rsa provider name: {0}",
                 rsaProviderName);

            // Get the protected section name.
            string protectedSectionName =
                ProtectedConfiguration.ProtectedDataSectionName;
            Console.WriteLine(
                "Protected section name: {0}",
                 protectedSectionName);
        }

        static void Main(string[] args)
        {

            // Get current and Rsa provider names.
            GetProviderName();

            // Get the providers' collection.
            GetProviders();
        }
    }    
}

Açıklamalar

sınıfı, ProtectedConfiguration hassas yapılandırma verilerini korumak için kullanılabilen sağlayıcılar hakkında bilgi edinmenizi sağlar. Genellikle standart sağlayıcıları kullanırsınız, ancak sınıfından ProtectedConfigurationProvider türeterek özel sağlayıcılar da oluşturabilirsiniz.

Korumalı yapılandırma hakkında daha fazla bilgi için bkz. Korumalı Yapılandırma Kullanarak Yapılandırma Bilgilerini Şifreleme.

Alanlar

DataProtectionProviderName

Veri koruma sağlayıcısının adı.

ProtectedDataSectionName

Korumalı veriler bölümünün adı.

RsaProviderName

RSA sağlayıcısının adı.

Özellikler

DefaultProvider

Varsayılan protected-configuration sağlayıcısının adını alır.

Providers

Yüklü korumalı yapılandırma sağlayıcılarının bir koleksiyonunu alır.

Şunlara uygulanır

Ürün Sürümler
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Ayrıca bkz.