BuildProviderCollection Klasa

Definicja

Reprezentuje kolekcję BuildProvider obiektów. Klasa ta nie może być dziedziczona.

public ref class BuildProviderCollection sealed : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.BuildProvider))]
public sealed class BuildProviderCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.BuildProvider))>]
type BuildProviderCollection = class
    inherit ConfigurationElementCollection
Public NotInheritable Class BuildProviderCollection
Inherits ConfigurationElementCollection
Dziedziczenie
Atrybuty

Przykłady

Ta sekcja zawiera dwa przykłady kodu. Pierwszy pokazuje, jak deklaratywnie określać wartości dla kilku właściwości BuildProviderCollection klasy. Drugi pokazuje, jak używać składowych BuildProviderCollection klasy.

Poniższy przykład pliku konfiguracji pokazuje, jak deklaratywnie określić wartości dla kilku właściwości BuildProviderCollection klasy.

<system.web>  
  <compilation>   
    <buildProviders>  
      <add extension=".aspx"   
        type="System.Web.Compilation.PageBuildProvider"  
         />  
      <add extension=".ascx"   
        type="System.Web.Compilation.UserControlBuildProvider"  
         />  
      <add extension=".master"   
        type="System.Web.Compilation.MasterPageBuildProvider"  
         />  
      <add extension=".asix"   
        type="System.Web.Compilation.ImageGeneratorBuildProvider"  
         />  
      <add extension=".asmx"   
        type="System.Web.Compilation.WebServiceBuildProvider"  
         />  
      <add extension=".ashx"   
        type="System.Web.Compilation.WebHandlerBuildProvider"  
         />  
      <add extension=".soap"   
        type="System.Web.Compilation.WebServiceBuildProvider"  
         />  
      <add extension=".resx"   
        type="System.Web.Compilation.ResXBuildProvider"  
        appliesTo="Resources" />  
      <add extension=".resources"   
        type="System.Web.Compilation.ResourcesBuildProvider"  
        appliesTo="Code, Resources" />  
      <add extension=".wsdl"   
        type="System.Web.Compilation.WsdlBuildProvider"  
        appliesTo="Code" />  
      <add extension=".xsd"   
        type="System.Web.Compilation.XsdBuildProvider"  
        appliesTo="Code" />  
    </buildProviders>  
  </compilation>  
</system.web>  

W poniższym przykładzie kodu pokazano, jak używać składowych BuildProviderCollection klasy.

#region Using directives

using System;
using System.Configuration;
using System.Web.Configuration;

#endregion

namespace Samples.Aspnet.SystemWebConfiguration
{
  class UsingBuildProviderCollection
  {
    static void Main(string[] args)
    {
      try
      {
        // Set the path of the config file.
        string configPath = "";

        // Get the Web application configuration object.
        Configuration config =
          WebConfigurationManager.OpenWebConfiguration(configPath);

        // Get the section related object.
        CompilationSection configSection =
          (CompilationSection)config.GetSection
          ("system.web/compilation");

        // Display title and info.
        Console.WriteLine("ASP.NET Configuration Info");
        Console.WriteLine();

        // Display Config details.
        Console.WriteLine("File Path: {0}",
          config.FilePath);
        Console.WriteLine("Section Path: {0}",
          configSection.SectionInformation.Name);

        // Display BuildProviderCollection count.
        Console.WriteLine("BuildProviderCollection count: {0}",
          configSection.BuildProviders.Count);

        // Create a new BuildProvider.
        BuildProvider myBuildProvider =
          new BuildProvider(".myres",
          "System.Web.Compilation.ResourcesBuildProvider");

        // Add an BuildProvider to the collection.
        configSection.BuildProviders.Add(myBuildProvider);

        // Create a second BuildProvider.
        BuildProvider myBuildProvider2 =
          new BuildProvider(".myres2",
          "System.Web.Compilation.ResourcesBuildProvider");

        // Add an BuildProvider to the collection.
        configSection.BuildProviders.Add(myBuildProvider2);

        // BuildProvider Collection
        int i = 1;
        int j = 1;
        foreach (BuildProvider BuildProviderItem in
          configSection.BuildProviders)
        {
          Console.WriteLine();
          Console.WriteLine("BuildProviders {0} Details:", i);
          Console.WriteLine("Type: {0}",
            BuildProviderItem.ElementInformation.Type);
          Console.WriteLine("Source: {0}",
            BuildProviderItem.ElementInformation.Source);
          Console.WriteLine("LineNumber: {0}",
            BuildProviderItem.ElementInformation.LineNumber);
          Console.WriteLine("Properties Count: {0}",
            BuildProviderItem.ElementInformation.Properties.Count);
          j = 1;
          foreach (PropertyInformation propertyItem in
            BuildProviderItem.ElementInformation.Properties)
          {
            Console.WriteLine("Property {0} Name: {1}", j,
              propertyItem.Name);
            Console.WriteLine("Property {0} Value: {1}", j,
              propertyItem.Value);
            j++;
          }
          i++;
        }

        // Remove a BuildProvider.
        configSection.BuildProviders.Remove(".myres2");

        // Remove an BuildProvider.
        configSection.BuildProviders.RemoveAt(
          configSection.BuildProviders.Count - 1);

        // Update if not locked.
        if (!configSection.SectionInformation.IsLocked)
        {
          config.Save();
          Console.WriteLine("** Configuration updated.");
        }
        else
        {
          Console.WriteLine("** Could not update, section is locked.");
        }
      }

      catch (Exception e)
      {
        // Unknown error.
        Console.WriteLine(e.ToString());
      }

      // Display and wait.
      Console.ReadLine();
    }
  }
}
Imports System.Configuration
Imports System.Web.Configuration

Namespace Samples.Aspnet.SystemWebConfiguration
  Class UsingBuildProviderCollection
    Public Shared Sub Main()
      Try
        ' Set the path of the config file.
        Dim configPath As String = ""

        ' Get the Web application configuration object.
        Dim config As System.Configuration.Configuration = _
         WebConfigurationManager.OpenWebConfiguration(configPath)

        ' Get the section related object.
        Dim configSection As _
         System.Web.Configuration.CompilationSection = _
         CType(config.GetSection("system.web/compilation"), _
         System.Web.Configuration.CompilationSection)

        ' Display title and info.
        Console.WriteLine("ASP.NET Configuration Info")
        Console.WriteLine()

        ' Display Config details.
        Console.WriteLine("File Path: {0}", _
         config.FilePath)
        Console.WriteLine("Section Path: {0}", _
         configSection.SectionInformation.Name)

        ' Display BuildProviderCollection count.
        Console.WriteLine("BuildProviderCollection count: {0}", _
          configSection.BuildProviders.Count)

        ' Create a new BuildProvider.
        Dim myBuildProvider As BuildProvider = _
          New BuildProvider(".myres", _
          "System.Web.Compilation.ResourcesBuildProvider")

        ' Add an BuildProvider to the collection.
        configSection.BuildProviders.Add(myBuildProvider)

        ' Create a second BuildProvider.
        Dim myBuildProvider2 As BuildProvider = _
          New BuildProvider(".myres2", _
          "System.Web.Compilation.ResourcesBuildProvider")

        ' Add an BuildProvider to the collection.
        configSection.BuildProviders.Add(myBuildProvider2)

        ' BuildProvider Collection
        Dim i = 1
        Dim j = 1
        For Each BuildProviderItem As _
          BuildProvider In configSection.BuildProviders
          Console.WriteLine()
          Console.WriteLine("BuildProvider {0} Details:", i)
          Console.WriteLine("Type: {0}", _
            BuildProviderItem.ElementInformation.Type)
          Console.WriteLine("Source: {0}", _
            BuildProviderItem.ElementInformation.Source)
          Console.WriteLine("LineNumber: {0}", _
            BuildProviderItem.ElementInformation.LineNumber)
          Console.WriteLine("Properties Count: {0}", _
            BuildProviderItem.ElementInformation.Properties.Count)
          j = 1
          For Each propertyItem As PropertyInformation In _
            BuildProviderItem.ElementInformation.Properties
            Console.WriteLine("Property {0} Name: {1}", j, _
              propertyItem.Name)
            Console.WriteLine("Property {0} Value: {1}", j, _
              propertyItem.Value)
            j = j + 1
          Next
          i = i + 1
        Next

        ' Remove an BuildProvider.
        configSection.BuildProviders.Remove(".myres2")

        ' Remove an BuildProvider.
        configSection.BuildProviders.RemoveAt( _
          configSection.BuildProviders.Count - 1)

        ' Update if not locked.
        If Not configSection.SectionInformation.IsLocked Then
          config.Save()
          Console.WriteLine("** Configuration updated.")
        Else
          Console.WriteLine("** Could not update, section is locked.")
        End If

      Catch e As Exception
        ' Unknown error.
        Console.WriteLine(e.ToString())
      End Try

      ' Display and wait
      Console.ReadLine()
    End Sub
  End Class
End Namespace

Uwagi

Służy BuildProviderCollection do kompilowania niestandardowych plików zasobów. Możesz mieć dowolną liczbę dostawców kompilacji. Element BuildProviderCollection nie odwołuje się do żadnego rzeczywistego elementu w bazowym pliku konfiguracji. Jest to konstrukcja, która umożliwia łatwy dostęp do zawartych w nim informacji kompilacji.

Konstruktory

BuildProviderCollection()

Inicjuje nowe wystąpienie klasy BuildProviderCollection.

Właściwości

AddElementName

Pobiera lub ustawia nazwę ConfigurationElement obiektu do skojarzenia z operacją dodawania w ConfigurationElementCollection przypadku zastąpienia w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
ClearElementName

Pobiera lub ustawia nazwę, ConfigurationElement która ma być skojarzona z operacją wyczyść w przypadku zastąpienia w ConfigurationElementCollection klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
CollectionType

Pobiera typ .ConfigurationElementCollection

(Odziedziczone po ConfigurationElementCollection)
Count

Pobiera liczbę elementów w kolekcji.

(Odziedziczone po ConfigurationElementCollection)
CurrentConfiguration

Pobiera odwołanie do wystąpienia najwyższego poziomu Configuration , które reprezentuje hierarchię konfiguracji, do którego należy bieżące ConfigurationElement wystąpienie.

(Odziedziczone po ConfigurationElement)
ElementInformation

ElementInformation Pobiera obiekt, który zawiera niezstosowalne informacje i funkcje ConfigurationElement obiektu.

(Odziedziczone po ConfigurationElement)
ElementName

Pobiera nazwę używaną do identyfikowania tej kolekcji elementów w pliku konfiguracji podczas zastępowania w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
ElementProperty

ConfigurationElementProperty Pobiera obiekt reprezentujący ConfigurationElement sam obiekt.

(Odziedziczone po ConfigurationElement)
EmitClear

Pobiera lub ustawia wartość określającą, czy kolekcja została wyczyszczone.

(Odziedziczone po ConfigurationElementCollection)
EvaluationContext

ContextInformation Pobiera obiekt dla ConfigurationElement obiektu.

(Odziedziczone po ConfigurationElement)
HasContext

Pobiera wartość wskazującą, czy CurrentConfiguration właściwość to null.

(Odziedziczone po ConfigurationElement)
IsSynchronized

Pobiera wartość wskazującą, czy dostęp do kolekcji jest synchronizowany.

(Odziedziczone po ConfigurationElementCollection)
Item[ConfigurationProperty]

Pobiera lub ustawia właściwość lub atrybut tego elementu konfiguracji.

(Odziedziczone po ConfigurationElement)
Item[Int32]

BuildProvider Pobiera obiekt w określonym indeksie kolekcji.

Item[String]

Pobiera element kolekcji BuildProvider na podstawie określonej nazwy.

LockAllAttributesExcept

Pobiera kolekcję zablokowanych atrybutów.

(Odziedziczone po ConfigurationElement)
LockAllElementsExcept

Pobiera kolekcję zablokowanych elementów.

(Odziedziczone po ConfigurationElement)
LockAttributes

Pobiera kolekcję zablokowanych atrybutów.

(Odziedziczone po ConfigurationElement)
LockElements

Pobiera kolekcję zablokowanych elementów.

(Odziedziczone po ConfigurationElement)
LockItem

Pobiera lub ustawia wartość wskazującą, czy element jest zablokowany.

(Odziedziczone po ConfigurationElement)
Properties

Pobiera kolekcję właściwości.

(Odziedziczone po ConfigurationElement)
RemoveElementName

Pobiera lub ustawia nazwę ConfigurationElement obiektu do skojarzenia z operacją usuwania w ConfigurationElementCollection przypadku zastąpienia w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
SyncRoot

Pobiera obiekt używany do synchronizowania dostępu do obiektu ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
ThrowOnDuplicate

Pobiera wartość wskazującą, czy próba dodania duplikatu ConfigurationElement ConfigurationElementCollection do elementu spowoduje zgłoszenie wyjątku.

(Odziedziczone po ConfigurationElementCollection)

Metody

Add(BuildProvider)

BuildProvider Dodaje obiekt do obiektu BuildProviderCollection.

BaseAdd(ConfigurationElement)

Dodaje element konfiguracji do elementu ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
BaseAdd(ConfigurationElement, Boolean)

Dodaje element konfiguracji do kolekcji elementów konfiguracji.

(Odziedziczone po ConfigurationElementCollection)
BaseAdd(Int32, ConfigurationElement)

Dodaje element konfiguracji do kolekcji elementów konfiguracji.

(Odziedziczone po ConfigurationElementCollection)
BaseClear()

Usuwa wszystkie obiekty elementów konfiguracji z kolekcji.

(Odziedziczone po ConfigurationElementCollection)
BaseGet(Int32)

Pobiera element konfiguracji w określonej lokalizacji indeksu.

(Odziedziczone po ConfigurationElementCollection)
BaseGet(Object)

Zwraca element konfiguracji z określonym kluczem.

(Odziedziczone po ConfigurationElementCollection)
BaseGetAllKeys()

Zwraca tablicę kluczy dla wszystkich elementów konfiguracji zawartych w obiekcie ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
BaseGetKey(Int32)

Pobiera klucz dla ConfigurationElement elementu w określonej lokalizacji indeksu.

(Odziedziczone po ConfigurationElementCollection)
BaseIndexOf(ConfigurationElement)

Wskazuje indeks określonego ConfigurationElementelementu .

(Odziedziczone po ConfigurationElementCollection)
BaseIsRemoved(Object)

Wskazuje, czy ConfigurationElement element z określonym kluczem został usunięty z elementu ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
BaseRemove(Object)

Usuwa obiekt ConfigurationElement z kolekcji.

(Odziedziczone po ConfigurationElementCollection)
BaseRemoveAt(Int32)

Usuwa obiekt ConfigurationElement w określonej lokalizacji indeksu.

(Odziedziczone po ConfigurationElementCollection)
Clear()

Czyści wszystkie BuildProvider obiekty z obiektu BuildProviderCollection.

CopyTo(ConfigurationElement[], Int32)

Kopiuje zawartość obiektu ConfigurationElementCollection do tablicy.

(Odziedziczone po ConfigurationElementCollection)
CreateNewElement()

Po zastąpieniu w klasie pochodnej program tworzy nowy ConfigurationElementelement .

(Odziedziczone po ConfigurationElementCollection)
CreateNewElement(String)

Tworzy nowy ConfigurationElement element po zastąpieniu w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
DeserializeElement(XmlReader, Boolean)

Odczytuje kod XML z pliku konfiguracji.

(Odziedziczone po ConfigurationElement)
Equals(Object)

Porównuje obiekt ConfigurationElementCollection z określonym obiektem.

(Odziedziczone po ConfigurationElementCollection)
GetElementKey(ConfigurationElement)

Pobiera klucz elementu dla określonego elementu konfiguracji podczas zastępowania w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
GetEnumerator()

Pobiera element IEnumerator , który jest używany do iterowania przez element ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
GetHashCode()

Pobiera unikatową wartość reprezentującą ConfigurationElementCollection wystąpienie.

(Odziedziczone po ConfigurationElementCollection)
GetTransformedAssemblyString(String)

Zwraca przekształconą wersję określonej nazwy zestawu.

(Odziedziczone po ConfigurationElement)
GetTransformedTypeString(String)

Zwraca przekształconą wersję określonej nazwy typu.

(Odziedziczone po ConfigurationElement)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
Init()

ConfigurationElement Ustawia obiekt na stan początkowy.

(Odziedziczone po ConfigurationElement)
InitializeDefault()

Służy do inicjowania domyślnego zestawu wartości dla ConfigurationElement obiektu.

(Odziedziczone po ConfigurationElement)
IsElementName(String)

Wskazuje, czy określony ConfigurationElement element istnieje w obiekcie ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
IsElementRemovable(ConfigurationElement)

Wskazuje, czy określony ConfigurationElement element można usunąć z obiektu ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
IsModified()

Wskazuje, czy ConfigurationElementCollection ta operacja została zmodyfikowana od czasu ostatniego zapisania lub załadowania podczas zastępowania w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
IsReadOnly()

Wskazuje, czy ConfigurationElementCollection obiekt jest tylko do odczytu.

(Odziedziczone po ConfigurationElementCollection)
ListErrors(IList)

Dodaje błędy nieprawidłowej właściwości w tym ConfigurationElement obiekcie i we wszystkich podelementach do przekazanej listy.

(Odziedziczone po ConfigurationElement)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
OnDeserializeUnrecognizedAttribute(String, String)

Pobiera wartość wskazującą, czy podczas deserializacji napotkano nieznany atrybut.

(Odziedziczone po ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

Powoduje, że system konfiguracji zgłasza wyjątek.

(Odziedziczone po ConfigurationElementCollection)
OnRequiredPropertyNotFound(String)

Zgłasza wyjątek, gdy nie znaleziono wymaganej właściwości.

(Odziedziczone po ConfigurationElement)
PostDeserialize()

Wywoływana po deserializacji.

(Odziedziczone po ConfigurationElement)
PreSerialize(XmlWriter)

Wywoływane przed serializacji.

(Odziedziczone po ConfigurationElement)
Remove(String)

BuildProvider Usuwa obiekt z obiektu BuildProviderCollection.

RemoveAt(Int32)

BuildProvider Usuwa obiekt w określonym indeksie z obiektu BuildProviderCollection.

Reset(ConfigurationElement)

Resetuje element ConfigurationElementCollection do stanu niezmodyfikowanego, gdy zostanie zastąpiony w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
ResetModified()

Resetuje wartość IsModified() właściwości do false wartości podczas zastępowania w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
SerializeElement(XmlWriter, Boolean)

Zapisuje dane konfiguracji do elementu XML w pliku konfiguracji podczas zastępowania w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
SerializeToXmlElement(XmlWriter, String)

Zapisuje zewnętrzne tagi tego elementu konfiguracji do pliku konfiguracji po zaimplementowaniu w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

Ustawia właściwość na określoną wartość.

(Odziedziczone po ConfigurationElement)
SetReadOnly()

IsReadOnly() Ustawia właściwość obiektu ConfigurationElementCollection i dla wszystkich elementów podrzędnych.

(Odziedziczone po ConfigurationElementCollection)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

Odwraca efekt scalania informacji o konfiguracji z różnych poziomów hierarchii konfiguracji.

(Odziedziczone po ConfigurationElementCollection)

Jawne implementacje interfejsu

ICollection.CopyTo(Array, Int32)

Kopiuje element ConfigurationElementCollection do tablicy.

(Odziedziczone po ConfigurationElementCollection)

Metody rozszerzania

Cast<TResult>(IEnumerable)

Rzutuje elementy elementu IEnumerable na określony typ.

OfType<TResult>(IEnumerable)

Filtruje elementy IEnumerable elementu na podstawie określonego typu.

AsParallel(IEnumerable)

Umożliwia równoległość zapytania.

AsQueryable(IEnumerable)

Konwertuje element IEnumerable na .IQueryable

Dotyczy

Zobacz też