|
Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
|
Tradução
Original
|
Classe ConfigurationLockCollection
Namespace: System.Configuration
Assembly: System.Configuration (em System.Configuration.dll)
O tipo ConfigurationLockCollection expõe os membros a seguir.
| Nome | Descrição | |
|---|---|---|
![]() | AttributeList | |
![]() | Count | |
![]() | HasParentElements | |
![]() | IsModified | |
![]() | IsSynchronized | |
![]() | SyncRoot |
| Nome | Descrição | |
|---|---|---|
![]() | Add | |
![]() | Clear | |
![]() | Contains | |
![]() | CopyTo | |
![]() | Equals(Object) | |
![]() | GetEnumerator | |
![]() | GetHashCode | |
![]() | GetType | |
![]() | IsReadOnly | |
![]() | Remove | |
![]() | SetFromList | |
![]() | ToString |
| Nome | Descrição | |
|---|---|---|
![]() | AsParallel | |
![]() | AsQueryable | |
![]() | Cast<TResult> | |
![]() | OfType<TResult> |
| Nome | Descrição | |
|---|---|---|
![]() ![]() | ICollection.CopyTo |
#region Using directives using System; using System.Configuration; using System.Web.Configuration; using System.Collections; using System.Text; #endregion namespace Samples.Aspnet.SystemWebConfiguration { class UsingConfigurationLockCollection { 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. AnonymousIdentificationSection configSection = (AnonymousIdentificationSection)config.GetSection ("system.web/anonymousIdentification"); // Display title and info. Console.WriteLine("Configuration Info"); Console.WriteLine(); // Display Config details. Console.WriteLine("File Path: {0}", config.FilePath); Console.WriteLine("Section Path: {0}", configSection.SectionInformation.Name); Console.WriteLine(); // Create a ConfigurationLockCollection object. ConfigurationLockCollection lockedAttribList; lockedAttribList = configSection.LockAttributes; // Add an attribute to the lock collection. if (!lockedAttribList.Contains("enabled")) { lockedAttribList.Add("enabled"); } if (!lockedAttribList.Contains("cookieless")) { lockedAttribList.Add("cookieless"); } // Count property. Console.WriteLine("Collection Count: {0}", lockedAttribList.Count); // AttributeList method. Console.WriteLine("AttributeList: {0}", lockedAttribList.AttributeList); // Contains method. Console.WriteLine("Contains 'enabled': {0}", lockedAttribList.Contains("enabled")); // HasParentElements property. Console.WriteLine("HasParentElements: {0}", lockedAttribList.HasParentElements); // IsModified property. Console.WriteLine("IsModified: {0}", lockedAttribList.IsModified); // IsReadOnly method. Console.WriteLine("IsReadOnly: {0}", lockedAttribList.IsReadOnly("enabled")); // Remove a configuration object // from the collection. lockedAttribList.Remove("cookieless"); // Clear the collection. lockedAttribList.Clear(); // Create an ArrayList to contain // the property items of the configuration // section. ArrayList configPropertyAL = new ArrayList(lockedAttribList.Count); foreach (PropertyInformation propertyItem in configSection.ElementInformation.Properties) { configPropertyAL.Add(propertyItem.Name.ToString()); } // Copy the elements of the ArrayList to a string array. String[] myArr = (String[])configPropertyAL.ToArray(typeof(string)); // Create as a comma delimited list. string propList = string.Join(",", myArr); // Lock the items in the list. lockedAttribList.SetFromList(propList); } catch (Exception e) { // Unknown error. Console.WriteLine(e.ToString()); } // Display and wait. Console.ReadLine(); } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Função Server Core sem suporte), Windows Server 2008 R2 (Função Server Core com suporte com o SP1 ou posterior, Itanium sem suporte)
O .NET Framework não oferece suporte a todas as versões de cada plataforma. Para obter uma lista das versões com suporte, consulte .Requisitos de sistema do NET Framework.
