CompilationSection Třída
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Definuje nastavení konfigurace, která se používají k podpoře infrastruktury kompilace webových aplikací. Tato třída se nemůže dědit.
public ref class CompilationSection sealed : System::Configuration::ConfigurationSection
public sealed class CompilationSection : System.Configuration.ConfigurationSection
type CompilationSection = class
inherit ConfigurationSection
Public NotInheritable Class CompilationSection
Inherits ConfigurationSection
- Dědičnost
Příklady
Tento příklad ukazuje, jak zadat hodnoty deklarativní pro několik atributů oddílu compilation , které lze také získat přístup jako členy CompilationSection třídy.
Následující příklad konfiguračního souboru ukazuje, jak zadat hodnoty deklarativní pro compilation oddíl.
<system.web>
<compilation
tempDirectory=""
debug="False"
strict="False"
explicit="True"
batch="True"
batchTimeout="900"
maxBatchSize="1000"
maxBatchGeneratedFileSize="1000"
numRecompilesBeforeAppRestart="15"
defaultLanguage="vb"
targetFramework="4.0"
urlLinePragmas="False"
assemblyPostProcessorType="">
<assemblies>
<clear />
</assemblies>
<buildProviders>
<clear />
</buildProviders>
<expressionBuilders>
<clear />
</expressionBuilders>
</compilation>
</system.web>
Následující příklad kódu ukazuje, jak používat členy CompilationSection třídy.
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
#endregion
namespace Samples.Aspnet.SystemWebConfiguration
{
class UsingCompilationSection
{
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 Assemblies collection count.
Console.WriteLine("Assemblies Count: {0}",
configSection.Assemblies.Count);
// Display AssemblyPostProcessorType property.
Console.WriteLine("AssemblyPostProcessorType: {0}",
configSection.AssemblyPostProcessorType);
// Display Batch property.
Console.WriteLine("Batch: {0}", configSection.Batch);
// Set Batch property.
configSection.Batch = true;
// Display BatchTimeout property.
Console.WriteLine("BatchTimeout: {0}",
configSection.BatchTimeout);
// Set BatchTimeout property.
configSection.BatchTimeout = TimeSpan.FromMinutes(15);
// Display BuildProviders collection count.
Console.WriteLine("BuildProviders collection Count: {0}",
configSection.BuildProviders.Count);
// Display CodeSubDirectories collection count.
Console.WriteLine("CodeSubDirectories Count: {0}",
configSection.CodeSubDirectories.Count);
// Display Compilers collection count.
Console.WriteLine("Compilers Count: {0}",
configSection.Compilers.Count);
// Display Debug property.
Console.WriteLine("Debug: {0}",
configSection.Debug);
// Set Debug property.
configSection.Debug = false;
// Display DefaultLanguage property.
Console.WriteLine("DefaultLanguage: {0}",
configSection.DefaultLanguage);
// Set DefaultLanguage property.
configSection.DefaultLanguage = "vb";
// Display Explicit property.
Console.WriteLine("Explicit: {0}",
configSection.Explicit);
// Set Explicit property.
configSection.Explicit = true;
// Display ExpressionBuilders collection count.
Console.WriteLine("ExpressionBuilders Count: {0}",
configSection.ExpressionBuilders.Count);
// Display MaxBatchGeneratedFileSize property.
Console.WriteLine("MaxBatchGeneratedFileSize: {0}",
configSection.MaxBatchGeneratedFileSize);
// Set MaxBatchGeneratedFileSize property.
configSection.MaxBatchGeneratedFileSize = 1000;
// Display MaxBatchSize property.
Console.WriteLine("MaxBatchSize: {0}",
configSection.MaxBatchSize);
// Set MaxBatchSize property.
configSection.MaxBatchSize = 1000;
// Display NumRecompilesBeforeAppRestart property.
Console.WriteLine("NumRecompilesBeforeAppRestart: {0}",
configSection.NumRecompilesBeforeAppRestart);
// Set NumRecompilesBeforeAppRestart property.
configSection.NumRecompilesBeforeAppRestart = 15;
// Display Strict property.
Console.WriteLine("Strict: {0}",
configSection.Strict);
// Set Strict property.
configSection.Strict = false;
// Display TempDirectory property.
Console.WriteLine("TempDirectory: {0}", configSection.TempDirectory);
// Set TempDirectory property.
configSection.TempDirectory = "myTempDirectory";
// Display UrlLinePragmas property.
Console.WriteLine("UrlLinePragmas: {0}",
configSection.UrlLinePragmas);
// Set UrlLinePragmas property.
configSection.UrlLinePragmas = false;
// ExpressionBuilders Collection
int i = 1;
int j = 1;
foreach (ExpressionBuilder expressionBuilder in configSection.ExpressionBuilders)
{
Console.WriteLine();
Console.WriteLine("ExpressionBuilder {0} Details:", i);
Console.WriteLine("Type: {0}", expressionBuilder.ElementInformation.Type);
Console.WriteLine("Source: {0}", expressionBuilder.ElementInformation.Source);
Console.WriteLine("LineNumber: {0}", expressionBuilder.ElementInformation.LineNumber);
Console.WriteLine("Properties Count: {0}", expressionBuilder.ElementInformation.Properties.Count);
j = 1;
foreach (PropertyInformation propertyItem in expressionBuilder.ElementInformation.Properties)
{
Console.WriteLine("Property {0} Name: {1}", j, propertyItem.Name);
Console.WriteLine("Property {0} Value: {1}", j, propertyItem.Value);
j++;
}
i++;
}
// 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.Collections.Generic
Imports System.Text
Imports System.Configuration
Imports System.Web
Imports System.Web.Configuration
Namespace Samples.Aspnet.SystemWebConfiguration
Class UsingRoleManagerSection
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 Assemblies collection count.
Console.WriteLine("Assemblies Count: {0}", _
configSection.Assemblies.Count)
' Display AssemblyPostProcessorType property.
Console.WriteLine("AssemblyPostProcessorType: {0}", _
configSection.AssemblyPostProcessorType)
' Display Batch property.
Console.WriteLine("Batch: {0}", _
configSection.Batch)
' Set Batch property.
configSection.Batch = True
' Display BatchTimeout property.
Console.WriteLine("BatchTimeout: {0}", _
configSection.BatchTimeout)
' Set BatchTimeout property.
configSection.BatchTimeout = TimeSpan.FromMinutes(15)
' Display BuildProviders collection count.
Console.WriteLine("BuildProviders collection count: {0}", _
configSection.BuildProviders.Count)
' Display CodeSubDirectories property.
Console.WriteLine("CodeSubDirectories: {0}", _
configSection.CodeSubDirectories.Count)
' Display Compilers property.
Console.WriteLine("Compilers: {0}", _
configSection.Compilers.Count)
' Display Debug property.
Console.WriteLine("Debug: {0}", _
configSection.Debug)
' Set Debug property.
configSection.Debug = False
' Display DefaultLanguage property.
Console.WriteLine("DefaultLanguage: {0}", _
configSection.DefaultLanguage)
' Set DefaultLanguage property.
configSection.DefaultLanguage = "vb"
' Display Explicit property.
Console.WriteLine("Explicit: {0}", _
configSection.Explicit)
' Set Explicit property.
configSection.Explicit = True
' Display ExpressionBuilders collection count.
Console.WriteLine("ExpressionBuilders Count: {0}", _
configSection.ExpressionBuilders.Count)
' Display MaxBatchGeneratedFileSize property.
Console.WriteLine("MaxBatchGeneratedFileSize: {0}", _
configSection.MaxBatchGeneratedFileSize)
' Set MaxBatchGeneratedFileSize property.
configSection.MaxBatchGeneratedFileSize = 1000
' Display MaxBatchSize property.
Console.WriteLine("MaxBatchSize: {0}", _
configSection.MaxBatchSize)
' Set MaxBatchSize property.
configSection.MaxBatchSize = 1000
' Display NumRecompilesBeforeAppRestart property.
Console.WriteLine("NumRecompilesBeforeAppRestart: {0}", _
configSection.NumRecompilesBeforeAppRestart)
' Set NumRecompilesBeforeAppRestart property.
configSection.NumRecompilesBeforeAppRestart = 15
' Display Strict property.
Console.WriteLine("Strict: {0}", _
configSection.Strict)
' Set Strict property.
configSection.Strict = False
' Display TempDirectory property.
Console.WriteLine("TempDirectory: {0}", _
configSection.TempDirectory)
' Set TempDirectory property.
configSection.TempDirectory = "myTempDirectory"
' Display UrlLinePragmas property.
Console.WriteLine("UrlLinePragmas: {0}", _
configSection.UrlLinePragmas)
' Set UrlLinePragmas property.
configSection.UrlLinePragmas = False
' ExpressionBuilders Collection
Dim i = 1
Dim j = 1
For Each expressionBuilder As ExpressionBuilder In configSection.ExpressionBuilders()
Console.WriteLine()
Console.WriteLine("ExpressionBuilder {0} Details:", i)
Console.WriteLine("Type: {0}", expressionBuilder.ElementInformation.Type)
Console.WriteLine("Source: {0}", expressionBuilder.ElementInformation.Source)
Console.WriteLine("LineNumber: {0}", expressionBuilder.ElementInformation.LineNumber)
Console.WriteLine("Properties Count: {0}", expressionBuilder.ElementInformation.Properties.Count)
j = 1
For Each propertyItem As PropertyInformation In expressionBuilder.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
' 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
Poznámky
Třída CompilationSection poskytuje způsob, jak programově přistupovat a upravovat obsah compilation oddílu konfiguračního souboru.
Konstruktory
| Name | Description |
|---|---|
| CompilationSection() |
Inicializuje novou instanci CompilationSection třídy pomocí výchozího nastavení. |
Vlastnosti
| Name | Description |
|---|---|
| Assemblies |
Získá z AssemblyCollection toho CompilationSection. |
| AssemblyPostProcessorType |
Získá nebo nastaví hodnotu určující krok kompilace po procesu sestavení. |
| Batch |
Získá nebo nastaví hodnotu označující, zda je pokus o dávkové kompilace. |
| BatchTimeout |
Získá nebo nastaví časový limit pro dávkové kompilace v sekundách. |
| BuildProviders |
Získá kolekci BuildProviderCollectionCompilationSection třídy. |
| CodeSubDirectories |
Získá z CodeSubDirectoriesCollection toho CompilationSection. |
| Compilers |
Získá kolekci CompilerCollectionCompilationSection třídy. |
| ControlBuilderInterceptorType |
Získá nebo nastaví řetězec představující typ objektu použitý k zachycení objektu ControlBuilder a konfiguraci kontejneru. |
| CurrentConfiguration |
Získá odkaz na instanci nejvyšší úrovně Configuration, která představuje hierarchii konfigurace, do které patří aktuální instance ConfigurationElement. (Zděděno od ConfigurationElement) |
| Debug |
Získá nebo nastaví hodnotu určující, zda se mají kompilovat binární soubory vydané verze nebo ladicí binární soubory. |
| DefaultLanguage |
Získá nebo nastaví výchozí programovací jazyk pro použití v souborech dynamické kompilace. |
| DisableObsoleteWarnings |
Získá nebo nastaví, zda je nastavena hodnota konfigurace disableObsoleteWarnings v části Kompilace. |
| ElementInformation |
Získá ElementInformation objekt, který obsahuje neuzpůsobitelné informace a funkce ConfigurationElement objektu. (Zděděno od ConfigurationElement) |
| ElementProperty |
Získá ConfigurationElementProperty objekt, který představuje ConfigurationElement objekt sám. (Zděděno od ConfigurationElement) |
| EnablePrefetchOptimization |
Získá nebo nastaví hodnotu, která označuje, zda ASP.NET aplikace může využít Windows 8 předběžné načtení funkce. |
| EvaluationContext |
Získá objekt ContextInformation pro objekt ConfigurationElement. (Zděděno od ConfigurationElement) |
| Explicit |
Získá nebo nastaví hodnotu označující, zda použít možnost kompilace jazyka Microsoft Visual Basic |
| ExpressionBuilders |
Získá z ExpressionBuilderCollection toho CompilationSection. |
| FolderLevelBuildProviders |
Získá kolekci FolderLevelBuildProviderCollectionCompilationSection třídy, která představuje zprostředkovatele sestavení, které se používají při kompilaci. |
| HasContext |
Získá hodnotu, která určuje, zda CurrentConfiguration vlastnost je |
| Item[ConfigurationProperty] |
Získá nebo nastaví vlastnost nebo atribut tohoto elementu konfigurace. (Zděděno od ConfigurationElement) |
| Item[String] |
Získá nebo nastaví vlastnost, atribut nebo podřízený prvek tohoto konfiguračního elementu. (Zděděno od ConfigurationElement) |
| LockAllAttributesExcept |
Získá kolekci uzamčených atributů. (Zděděno od ConfigurationElement) |
| LockAllElementsExcept |
Získá kolekci uzamčených prvků. (Zděděno od ConfigurationElement) |
| LockAttributes |
Získá kolekci uzamčených atributů. (Zděděno od ConfigurationElement) |
| LockElements |
Získá kolekci uzamčených prvků. (Zděděno od ConfigurationElement) |
| LockItem |
Získá nebo nastaví hodnotu označující, zda je prvek uzamčen. (Zděděno od ConfigurationElement) |
| MaxBatchGeneratedFileSize |
Získá nebo nastaví maximální kombinovanou velikost vygenerovaných zdrojových souborů na dávkovou kompilaci. |
| MaxBatchSize |
Získá nebo nastaví maximální počet stránek na dávkovou kompilaci. |
| MaxConcurrentCompilations |
Získá nebo nastaví, zda je nastavena hodnota "maxConcurrentCompilations" v oddílu Kompilace. |
| NumRecompilesBeforeAppRestart |
Získá nebo nastaví počet dynamických rekompilů prostředků, ke kterým může dojít před restartováním aplikace. |
| OptimizeCompilations |
Získá nebo nastaví hodnotu, která označuje, zda kompilace musí být optimalizována. |
| ProfileGuidedOptimizations |
Získá nebo nastaví hodnotu, která označuje, zda je aplikace optimalizována pro nasazené prostředí. |
| Properties |
Získá kolekci vlastností. (Zděděno od ConfigurationElement) |
| SectionInformation |
SectionInformation Získá objekt, který obsahuje neuzpůsobitelné informace a funkce objektuConfigurationSection. (Zděděno od ConfigurationSection) |
| Strict |
Získá nebo nastaví možnost kompilace jazyka Visual Basic |
| TargetFramework |
Získá nebo nastaví verzi .NET Framework, který web cílí. |
| TempDirectory |
Získá nebo nastaví hodnotu, která určuje adresář, který se má použít pro dočasné úložiště souborů během kompilace. |
| UrlLinePragmas |
Získá nebo nastaví hodnotu označující, zda instrukce kompilátoru používají fyzické cesty nebo adresy URL. |
Metody
| Name | Description |
|---|---|
| DeserializeElement(XmlReader, Boolean) |
Načte XML z konfiguračního souboru. (Zděděno od ConfigurationElement) |
| DeserializeSection(XmlReader) |
Načte XML z konfiguračního souboru. (Zděděno od ConfigurationSection) |
| Equals(Object) |
Porovná aktuální ConfigurationElement instanci se zadaným objektem. (Zděděno od ConfigurationElement) |
| GetHashCode() |
Získá jedinečnou hodnotu představující aktuální ConfigurationElement instanci. (Zděděno od ConfigurationElement) |
| GetRuntimeObject() |
Vrátí vlastní objekt při přepsání v odvozené třídě. (Zděděno od ConfigurationSection) |
| GetTransformedAssemblyString(String) |
Vrátí transformovanou verzi zadaného názvu sestavení. (Zděděno od ConfigurationElement) |
| GetTransformedTypeString(String) |
Vrátí transformovanou verzi zadaného názvu typu. (Zděděno od ConfigurationElement) |
| GetType() |
Získá Type aktuální instance. (Zděděno od Object) |
| Init() |
Nastaví objekt ConfigurationElement na jeho počáteční stav. (Zděděno od ConfigurationElement) |
| InitializeDefault() |
Slouží k inicializaci výchozí sady hodnot pro objekt ConfigurationElement. (Zděděno od ConfigurationElement) |
| IsModified() |
Určuje, zda byl tento konfigurační prvek změněn od posledního uložení nebo načtení při implementaci v odvozené třídě. (Zděděno od ConfigurationSection) |
| IsReadOnly() |
Získá hodnotu určující, zda ConfigurationElement objekt je jen pro čtení. (Zděděno od ConfigurationElement) |
| ListErrors(IList) |
Přidá chyby neplatné vlastnosti v tomto ConfigurationElement objektu a ve všech dílčích poplatcích do předaného seznamu. (Zděděno od ConfigurationElement) |
| MemberwiseClone() |
Vytvoří mělkou kopii aktuálního Object. (Zděděno od Object) |
| OnDeserializeUnrecognizedAttribute(String, String) |
Získá hodnotu určující, zda neznámý atribut je zjištěn během deserializace. (Zděděno od ConfigurationElement) |
| OnDeserializeUnrecognizedElement(String, XmlReader) |
Získá hodnotu určující, zda neznámý prvek je zjištěn během deserializace. (Zděděno od ConfigurationElement) |
| OnRequiredPropertyNotFound(String) |
Vyvolá výjimku, pokud nebyla nalezena požadovaná vlastnost. (Zděděno od ConfigurationElement) |
| PostDeserialize() |
Volal po deserializaci. (Zděděno od ConfigurationElement) |
| PreSerialize(XmlWriter) |
Volá se před serializací. (Zděděno od ConfigurationElement) |
| Reset(ConfigurationElement) |
Obnoví vnitřní stav objektu ConfigurationElement , včetně zámků a kolekcí vlastností. (Zděděno od ConfigurationElement) |
| ResetModified() |
Obnoví hodnotu IsModified() metody na |
| SerializeElement(XmlWriter, Boolean) |
Zapíše obsah tohoto konfiguračního prvku do konfiguračního souboru při implementaci v odvozené třídě. (Zděděno od ConfigurationElement) |
| SerializeSection(ConfigurationElement, String, ConfigurationSaveMode) |
Vytvoří řetězec XML obsahující nerozčleněné zobrazení objektu ConfigurationSection jako jeden oddíl pro zápis do souboru. (Zděděno od ConfigurationSection) |
| SerializeToXmlElement(XmlWriter, String) |
Zapíše vnější značky tohoto konfiguračního prvku do konfiguračního souboru při implementaci v odvozené třídě. (Zděděno od ConfigurationElement) |
| SetPropertyValue(ConfigurationProperty, Object, Boolean) |
Nastaví vlastnost na zadanou hodnotu. (Zděděno od ConfigurationElement) |
| SetReadOnly() |
IsReadOnly() Nastaví vlastnost pro ConfigurationElement objekt a všechny dílčí prvky. (Zděděno od ConfigurationElement) |
| ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) |
Určuje, zda zadaný prvek má být serializován, když je hierarchie objektu konfigurace serializována pro zadanou cílovou verzi .NET Framework. (Zděděno od ConfigurationSection) |
| ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement) |
Určuje, zda má být zadaná vlastnost serializována, pokud je hierarchie objektu konfigurace serializována pro zadanou cílovou verzi .NET Framework. (Zděděno od ConfigurationSection) |
| ShouldSerializeSectionInTargetVersion(FrameworkName) |
Určuje, zda aktuální ConfigurationSection instance by měla být serializována, pokud je hierarchie objektů konfigurace serializována pro zadanou cílovou verzi .NET Framework. (Zděděno od ConfigurationSection) |
| ToString() |
Vrátí řetězec, který představuje aktuální objekt. (Zděděno od Object) |
| Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
Upraví objekt tak ConfigurationElement , aby odebral všechny hodnoty, které by neměly být uloženy. (Zděděno od ConfigurationElement) |