Język

AssemblyCollection Klasa

Definicja

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

public ref class AssemblyCollection sealed : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.AssemblyInfo))]
public sealed class AssemblyCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.AssemblyInfo))>]
type AssemblyCollection = class
    inherit ConfigurationElementCollection
Public NotInheritable Class AssemblyCollection
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 AssemblyCollection klasy. Drugi pokazuje, jak używać składowych AssemblyCollection klasy.

Poniższy przykładowy plik konfiguracji przedstawia sposób deklaratywnego określania wartości dla kilku właściwości AssemblyCollection klasy.

<system.web>
  <compilation>
    <assemblies>
      <add assembly="mscorlib" />
      <add assembly="System, Version=2.0.0.0, Culture=neutral,
        PublicKeyToken=b77a5c561934e089" />
      <add assembly="System.Configuration, Version=2.0.0.0,
        Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <add assembly="System.Web, Version=2.0.0.0, Culture=neutral,
        PublicKeyToken=b03f5f7f11d50a3a" />
      <add assembly="System.Data, Version=2.0.0.0, Culture=neutral,
        PublicKeyToken=b77a5c561934e089" />
      <add assembly="System.Web.Services, Version=2.0.0.0,
        Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral,
        PublicKeyToken=b77a5c561934e089" />
      <add assembly="System.Drawing, Version=2.0.0.0,
        Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <add assembly="System.EnterpriseServices, Version=2.0.0.0,
        Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <add assembly="System.Web.Mobile, Version=2.0.0.0,
        Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <add assembly="System.Web.UI.MobileControls.Adapters,
        Version=2.0.0.0, Culture=neutral,
        PublicKeyToken=b03f5f7f11d50a3a" />
      <add assembly="*" />
    </assemblies>
  </compilation>
</system.web>

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

#region Using directives

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

#endregion

namespace Samples.Aspnet.SystemWebConfiguration
{
  class UsingAssemblyCollection
  {
    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);

        // Create a new assembly reference.
        AssemblyInfo myAssembly = 
          new AssemblyInfo("MyAssembly, Version=1.0.0000.0, " +
          "Culture=neutral, Public KeyToken=b03f5f7f11d50a3a");
        // Add an assembly to the configuration.
        configSection.Assemblies.Add(myAssembly);

        // Add a second assembly reference.
        AssemblyInfo myAssembly2 = new AssemblyInfo("MyAssembly2");
        configSection.Assemblies.Add(myAssembly2);

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

        // Remove an assembly.
        configSection.Assemblies.Remove("MyAssembly, Version=1.0.0000.0, " +
          "Culture=neutral, Public KeyToken=b03f5f7f11d50a3a");

        // Remove an assembly.
        configSection.Assemblies.RemoveAt(configSection.Assemblies.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 UsingAssemblyCollection
    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)

        ' Create a new assembly reference.
        Dim myAssembly As AssemblyInfo = New AssemblyInfo("MyAssembly, " + _
        "Version=1.0.0000.0, Culture=neutral, Public KeyToken=b03f5f7f11d50a3a")
        ' Add an assembly to the configuration.
        configSection.Assemblies.Add(myAssembly)

        ' Add a second assembly reference.
        Dim myAssembly2 As AssemblyInfo = New AssemblyInfo("MyAssembly2")
        configSection.Assemblies.Add(myAssembly2)

        ' Assembly Collection
        Dim i = 1
        Dim j = 1
        For Each assemblyItem As AssemblyInfo In configSection.Assemblies
          Console.WriteLine()
          Console.WriteLine("Assemblies {0} Details:", i)
          Console.WriteLine("Type: {0}", assemblyItem.ElementInformation.Type)
          Console.WriteLine("Source: {0}", assemblyItem.ElementInformation.Source)
          Console.WriteLine("LineNumber: {0}", assemblyItem.ElementInformation.LineNumber)
          Console.WriteLine("Properties Count: {0}", assemblyItem.ElementInformation.Properties.Count)
          j = 1
          For Each propertyItem As PropertyInformation In assemblyItem.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 assembly.
        configSection.Assemblies.Remove("MyAssembly, Version=1.0.0000.0, " + _
          "Culture=neutral, Public KeyToken=b03f5f7f11d50a3a")

        ' Remove an assembly.
        configSection.Assemblies.RemoveAt(configSection.Assemblies.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

Klasa AssemblyCollection nie odwołuje się do żadnego rzeczywistego elementu w bazowym pliku konfiguracji. Jest to konstrukcja, która umożliwia dostęp do zawartych w nim informacji o zestawie.

Konstruktory

Nazwa Opis
AssemblyCollection()

Inicjuje nowe wystąpienie klasy AssemblyCollection.

Właściwości

Nazwa Opis
AddElementName

Pobiera lub ustawia nazwę ConfigurationElement do skojarzenia z operacją dodawania w ConfigurationElementCollection podczas zastępowania w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
ClearElementName

Pobiera lub ustawia nazwę ConfigurationElement do skojarzenia z operacją clear w ConfigurationElementCollection po zastąpieniu w 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 wystąpienie ConfigurationElement.

(Odziedziczone po ConfigurationElement)
ElementInformation

Pobiera obiekt ElementInformation zawierający informacje i funkcje obiektu ConfigurationElement, które nie można dostosowywać.

(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

Pobiera obiekt ConfigurationElementProperty reprezentujący sam obiekt ConfigurationElement.

(Odziedziczone po ConfigurationElement)
EmitClear

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

(Odziedziczone po ConfigurationElementCollection)
EvaluationContext

Pobiera obiekt ContextInformation dla obiektu ConfigurationElement.

(Odziedziczone po ConfigurationElement)
HasContext

Pobiera wartość wskazującą, czy właściwość CurrentConfiguration jest 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]

Pobiera lub ustawia wartość AssemblyInfo w określonym indeksie w obiekcie AssemblyCollection.

Item[String]

Pobiera element zidentyfikowany przez określoną nazwę zestawu.

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 do skojarzenia z operacją usuwania w ConfigurationElementCollection po zastąpieniu w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
SyncRoot

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

(Odziedziczone po ConfigurationElementCollection)
ThrowOnDuplicate

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

(Odziedziczone po ConfigurationElementCollection)

Metody

Nazwa Opis
Add(AssemblyInfo)

AssemblyInfo Dodaje obiekt do kolekcjiAssemblyCollection.

BaseAdd(ConfigurationElement, Boolean)

Dodaje element konfiguracji do kolekcji elementów konfiguracji.

(Odziedziczone po ConfigurationElementCollection)
BaseAdd(ConfigurationElement)

Dodaje element konfiguracji do ConfigurationElementCollection.

(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 ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
BaseGetKey(Int32)

Pobiera klucz dla ConfigurationElement w określonej lokalizacji indeksu.

(Odziedziczone po ConfigurationElementCollection)
BaseIndexOf(ConfigurationElement)

Wskazuje indeks określonego ConfigurationElement.

(Odziedziczone po ConfigurationElementCollection)
BaseIsRemoved(Object)

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

(Odziedziczone po ConfigurationElementCollection)
BaseRemove(Object)

Usuwa ConfigurationElement z kolekcji.

(Odziedziczone po ConfigurationElementCollection)
BaseRemoveAt(Int32)

Usuwa ConfigurationElement w określonej lokalizacji indeksu.

(Odziedziczone po ConfigurationElementCollection)
Clear()

Czyści wszystkie AssemblyInfo obiekty z kolekcji AssemblyCollection .

CopyTo(ConfigurationElement[], Int32)

Kopiuje zawartość ConfigurationElementCollection do tablicy.

(Odziedziczone po ConfigurationElementCollection)
CreateNewElement()

Po zastąpieniu w klasie pochodnej tworzy nowy ConfigurationElementelement .

(Odziedziczone po ConfigurationElementCollection)
CreateNewElement(String)

Tworzy nowy ConfigurationElement podczas zastępowania w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
DeserializeElement(XmlReader, Boolean)

Odczytuje kod XML z pliku konfiguracji.

(Odziedziczone po ConfigurationElement)
Equals(Object)

Porównuje 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 używany do iterowania przez element ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
GetHashCode()

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

(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()

Pobiera Type bieżącego wystąpienia.

(Odziedziczone po Object)
Init()

Ustawia obiekt ConfigurationElement na stan początkowy.

(Odziedziczone po ConfigurationElement)
InitializeDefault()

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

(Odziedziczone po ConfigurationElement)
IsElementName(String)

Wskazuje, czy określony ConfigurationElement istnieje w ConfigurationElementCollection.

(Odziedziczone po ConfigurationElementCollection)
IsElementRemovable(ConfigurationElement)

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

(Odziedziczone po ConfigurationElementCollection)
IsModified()

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

(Odziedziczone po ConfigurationElementCollection)
IsReadOnly()

Wskazuje, czy obiekt ConfigurationElementCollection jest tylko do odczytu.

(Odziedziczone po ConfigurationElementCollection)
ListErrors(IList)

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

(Odziedziczone po ConfigurationElement)
MemberwiseClone()

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

(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 można odnaleźć wymaganej właściwości.

(Odziedziczone po ConfigurationElement)
PostDeserialize()

Wywoływana po deserializacji.

(Odziedziczone po ConfigurationElement)
PreSerialize(XmlWriter)

Wywoływana przed serializacji.

(Odziedziczone po ConfigurationElement)
Remove(String)

Usuwa AssemblyInfo obiekt z kolekcji AssemblyCollection .

RemoveAt(Int32)

Usuwa AssemblyInfo obiekt z kolekcji AssemblyCollection .

Reset(ConfigurationElement)

Resetuje ConfigurationElementCollection do stanu niezmodyfikowanego podczas zastępowania w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
ResetModified()

Resetuje wartość właściwości IsModified(), aby false po zastąpieniu w klasie pochodnej.

(Odziedziczone po ConfigurationElementCollection)
SerializeElement(XmlWriter, Boolean)

Zapisuje dane konfiguracji do elementu XML w pliku konfiguracji po zastąpieniu 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()

Ustawia właściwość IsReadOnly() dla 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

Nazwa Opis
ICollection.CopyTo(Array, Int32)

Kopiuje ConfigurationElementCollection do tablicy.

(Odziedziczone po ConfigurationElementCollection)

Metody rozszerzania

Nazwa Opis
AsParallel(IEnumerable)

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

AsQueryable(IEnumerable)

Konwertuje IEnumerable na IQueryable.

Cast<TResult>(IEnumerable)

Rzutuje elementy IEnumerable do określonego typu.

OfType<TResult>(IEnumerable)

Filtruje elementy IEnumerable na podstawie określonego typu.

Dotyczy

Zobacz też