AssemblyCollection Klass
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Representerar en samling AssemblyInfo objekt. Det går inte att ärva den här klassen.
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
- Arv
- Attribut
Exempel
Det här avsnittet innehåller två kodexempel. Den första visar hur du deklarativt anger värden för flera egenskaper för AssemblyCollection klassen. Den andra visar hur du använder medlemmar i AssemblyCollection klassen.
Följande konfigurationsfilexempel visar hur du deklarativt anger värden för flera egenskaper för AssemblyCollection klassen.
<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>
Följande kodexempel visar hur du använder medlemmar i AssemblyCollection klassen.
#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
Kommentarer
Klassen AssemblyCollection refererar inte till något faktiskt element i den underliggande konfigurationsfilen. Det är en konstruktion som ger åtkomst till den sammansättningsinformation som den innehåller.
Konstruktorer
| Name | Description |
|---|---|
| AssemblyCollection() |
Initierar en ny instans av AssemblyCollection klassen. |
Egenskaper
| Name | Description |
|---|---|
| AddElementName |
Hämtar eller anger namnet på den ConfigurationElement som ska associeras med lägg till-åtgärden i när den ConfigurationElementCollection åsidosättas i en härledd klass. (Ärvd från ConfigurationElementCollection) |
| ClearElementName |
Hämtar eller anger namnet på den ConfigurationElement som ska associeras med clear-åtgärden i när den ConfigurationElementCollection åsidosättas i en härledd klass. (Ärvd från ConfigurationElementCollection) |
| CollectionType |
Hämtar typen av ConfigurationElementCollection. (Ärvd från ConfigurationElementCollection) |
| Count |
Hämtar antalet element i samlingen. (Ärvd från ConfigurationElementCollection) |
| CurrentConfiguration |
Hämtar en referens till den översta instansen Configuration som representerar konfigurationshierarkin som den aktuella ConfigurationElement instansen tillhör. (Ärvd från ConfigurationElement) |
| ElementInformation |
Hämtar ett ElementInformation objekt som innehåller den icke-anpassningsbara informationen och funktionerna i ConfigurationElement objektet. (Ärvd från ConfigurationElement) |
| ElementName |
Hämtar namnet som används för att identifiera den här samlingen med element i konfigurationsfilen när den åsidosättas i en härledd klass. (Ärvd från ConfigurationElementCollection) |
| ElementProperty |
Hämtar objektet ConfigurationElementProperty som representerar ConfigurationElement själva objektet. (Ärvd från ConfigurationElement) |
| EmitClear |
Hämtar eller anger ett värde som anger om samlingen har rensats. (Ärvd från ConfigurationElementCollection) |
| EvaluationContext |
Hämtar ContextInformation-objektet för ConfigurationElement-objektet. (Ärvd från ConfigurationElement) |
| HasContext |
Hämtar ett värde som anger om egenskapen CurrentConfiguration är |
| IsSynchronized |
Hämtar ett värde som anger om åtkomsten till samlingen synkroniseras. (Ärvd från ConfigurationElementCollection) |
| Item[ConfigurationProperty] |
Hämtar eller anger en egenskap eller ett attribut för det här konfigurationselementet. (Ärvd från ConfigurationElement) |
| Item[Int32] |
Hämtar eller anger AssemblyInfo vid det angivna indexet AssemblyCollectioni . |
| Item[String] |
Hämtar objektet som identifieras med det angivna sammansättningsnamnet. |
| LockAllAttributesExcept |
Hämtar samlingen med låsta attribut. (Ärvd från ConfigurationElement) |
| LockAllElementsExcept |
Hämtar samlingen med låsta element. (Ärvd från ConfigurationElement) |
| LockAttributes |
Hämtar samlingen med låsta attribut. (Ärvd från ConfigurationElement) |
| LockElements |
Hämtar samlingen med låsta element. (Ärvd från ConfigurationElement) |
| LockItem |
Hämtar eller anger ett värde som anger om elementet är låst. (Ärvd från ConfigurationElement) |
| Properties |
Hämtar samlingen med egenskaper. (Ärvd från ConfigurationElement) |
| RemoveElementName |
Hämtar eller anger namnet på den ConfigurationElement som ska associeras med borttagningsåtgärden i när den ConfigurationElementCollection åsidosättas i en härledd klass. (Ärvd från ConfigurationElementCollection) |
| SyncRoot |
Hämtar ett objekt som används för att synkronisera åtkomsten ConfigurationElementCollectiontill . (Ärvd från ConfigurationElementCollection) |
| ThrowOnDuplicate |
Hämtar ett värde som anger om ett försök att lägga till en dubblett ConfigurationElement till ConfigurationElementCollection kommer att orsaka ett undantagsfel. (Ärvd från ConfigurationElementCollection) |
Metoder
| Name | Description |
|---|---|
| Add(AssemblyInfo) |
Lägger till ett AssemblyInfo objekt i AssemblyCollection samlingen. |
| BaseAdd(ConfigurationElement, Boolean) |
Lägger till ett konfigurationselement i konfigurationselementsamlingen. (Ärvd från ConfigurationElementCollection) |
| BaseAdd(ConfigurationElement) |
Lägger till ett konfigurationselement i ConfigurationElementCollection. (Ärvd från ConfigurationElementCollection) |
| BaseAdd(Int32, ConfigurationElement) |
Lägger till ett konfigurationselement i konfigurationselementsamlingen. (Ärvd från ConfigurationElementCollection) |
| BaseClear() |
Tar bort alla konfigurationselementobjekt från samlingen. (Ärvd från ConfigurationElementCollection) |
| BaseGet(Int32) |
Hämtar konfigurationselementet på den angivna indexplatsen. (Ärvd från ConfigurationElementCollection) |
| BaseGet(Object) |
Returnerar konfigurationselementet med den angivna nyckeln. (Ärvd från ConfigurationElementCollection) |
| BaseGetAllKeys() |
Returnerar en matris med nycklarna för alla konfigurationselement som finns i ConfigurationElementCollection. (Ärvd från ConfigurationElementCollection) |
| BaseGetKey(Int32) |
Hämtar nyckeln för ConfigurationElement på den angivna indexplatsen. (Ärvd från ConfigurationElementCollection) |
| BaseIndexOf(ConfigurationElement) |
Anger indexet för den angivna ConfigurationElement. (Ärvd från ConfigurationElementCollection) |
| BaseIsRemoved(Object) |
Anger om ConfigurationElement med den angivna nyckeln har tagits bort från ConfigurationElementCollection. (Ärvd från ConfigurationElementCollection) |
| BaseRemove(Object) |
Tar bort en ConfigurationElement från samlingen. (Ärvd från ConfigurationElementCollection) |
| BaseRemoveAt(Int32) |
Tar ConfigurationElement bort på den angivna indexplatsen. (Ärvd från ConfigurationElementCollection) |
| Clear() |
Rensar alla AssemblyInfo objekt från AssemblyCollection samlingen. |
| CopyTo(ConfigurationElement[], Int32) |
Kopierar innehållet i ConfigurationElementCollection till en matris. (Ärvd från ConfigurationElementCollection) |
| CreateNewElement() |
När du åsidosättas i en härledd klass skapar du en ny ConfigurationElement. (Ärvd från ConfigurationElementCollection) |
| CreateNewElement(String) |
Skapar en ny ConfigurationElement när den åsidosättas i en härledd klass. (Ärvd från ConfigurationElementCollection) |
| DeserializeElement(XmlReader, Boolean) |
Läser XML från konfigurationsfilen. (Ärvd från ConfigurationElement) |
| Equals(Object) |
ConfigurationElementCollection Jämför med det angivna objektet. (Ärvd från ConfigurationElementCollection) |
| GetElementKey(ConfigurationElement) |
Hämtar elementnyckeln för ett angivet konfigurationselement när det åsidosättas i en härledd klass. (Ärvd från ConfigurationElementCollection) |
| GetEnumerator() |
Hämtar en IEnumerator som används för att iterera via ConfigurationElementCollection. (Ärvd från ConfigurationElementCollection) |
| GetHashCode() |
Hämtar ett unikt värde som representerar instansen ConfigurationElementCollection . (Ärvd från ConfigurationElementCollection) |
| GetTransformedAssemblyString(String) |
Returnerar den transformerade versionen av det angivna sammansättningsnamnet. (Ärvd från ConfigurationElement) |
| GetTransformedTypeString(String) |
Returnerar den transformerade versionen av det angivna typnamnet. (Ärvd från ConfigurationElement) |
| GetType() |
Hämtar den aktuella instansen Type . (Ärvd från Object) |
| Init() |
Anger objektets ConfigurationElement ursprungliga tillstånd. (Ärvd från ConfigurationElement) |
| InitializeDefault() |
Används för att initiera en standarduppsättning med värden för ConfigurationElement objektet. (Ärvd från ConfigurationElement) |
| IsElementName(String) |
Anger om den angivna ConfigurationElement finns i ConfigurationElementCollection. (Ärvd från ConfigurationElementCollection) |
| IsElementRemovable(ConfigurationElement) |
Anger om den angivna ConfigurationElement kan tas bort från ConfigurationElementCollection. (Ärvd från ConfigurationElementCollection) |
| IsModified() |
Anger om detta ConfigurationElementCollection har ändrats sedan det senast sparades eller lästes in när det åsidosattes i en härledd klass. (Ärvd från ConfigurationElementCollection) |
| IsReadOnly() |
Anger om objektet ConfigurationElementCollection är skrivskyddat. (Ärvd från ConfigurationElementCollection) |
| ListErrors(IList) |
Lägger till felen invalid-property i det här ConfigurationElement objektet, och i alla underelement, i den överförda listan. (Ärvd från ConfigurationElement) |
| MemberwiseClone() |
Skapar en ytlig kopia av den aktuella Object. (Ärvd från Object) |
| OnDeserializeUnrecognizedAttribute(String, String) |
Hämtar ett värde som anger om ett okänt attribut påträffas under deserialiseringen. (Ärvd från ConfigurationElement) |
| OnDeserializeUnrecognizedElement(String, XmlReader) |
Gör att konfigurationssystemet utlöser ett undantag. (Ärvd från ConfigurationElementCollection) |
| OnRequiredPropertyNotFound(String) |
Utlöser ett undantag när en obligatorisk egenskap inte hittas. (Ärvd från ConfigurationElement) |
| PostDeserialize() |
Anropas efter deserialisering. (Ärvd från ConfigurationElement) |
| PreSerialize(XmlWriter) |
Anropas före serialisering. (Ärvd från ConfigurationElement) |
| Remove(String) |
Tar bort ett AssemblyInfo objekt från AssemblyCollection samlingen. |
| RemoveAt(Int32) |
Tar bort ett AssemblyInfo objekt från AssemblyCollection samlingen. |
| Reset(ConfigurationElement) |
Återställer ConfigurationElementCollection till dess oförändrade tillstånd när det åsidosättas i en härledd klass. (Ärvd från ConfigurationElementCollection) |
| ResetModified() |
Återställer värdet för egenskapen till IsModified() när det |
| SerializeElement(XmlWriter, Boolean) |
Skriver konfigurationsdata till ett XML-element i konfigurationsfilen när de åsidosättas i en härledd klass. (Ärvd från ConfigurationElementCollection) |
| SerializeToXmlElement(XmlWriter, String) |
Skriver de yttre taggarna för det här konfigurationselementet till konfigurationsfilen när det implementeras i en härledd klass. (Ärvd från ConfigurationElement) |
| SetPropertyValue(ConfigurationProperty, Object, Boolean) |
Anger en egenskap till det angivna värdet. (Ärvd från ConfigurationElement) |
| SetReadOnly() |
IsReadOnly() Anger egenskapen för ConfigurationElementCollection objektet och för alla underelement. (Ärvd från ConfigurationElementCollection) |
| ToString() |
Returnerar en sträng som representerar det aktuella objektet. (Ärvd från Object) |
| Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
Ändrar effekten av sammanslagning av konfigurationsinformation från olika nivåer i konfigurationshierarkin. (Ärvd från ConfigurationElementCollection) |
Explicita gränssnittsimplementeringar
| Name | Description |
|---|---|
| ICollection.CopyTo(Array, Int32) |
Kopierar ConfigurationElementCollection till en matris. (Ärvd från ConfigurationElementCollection) |
Tilläggsmetoder
| Name | Description |
|---|---|
| AsParallel(IEnumerable) |
Möjliggör parallellisering av en fråga. |
| AsQueryable(IEnumerable) |
Konverterar en IEnumerable till en IQueryable. |
| Cast<TResult>(IEnumerable) |
Omvandlar elementen i en IEnumerable till den angivna typen. |
| OfType<TResult>(IEnumerable) |
Filtrerar elementen i en IEnumerable baserat på en angiven typ. |