Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Net / System / Net / Configuration / SettingsSection.cs / 1 / SettingsSection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net.Configuration
{
using System.Configuration;
using System.Threading;
public sealed class SettingsSection : ConfigurationSection
{
// Placeholder for [....] to add code to load all configuration
// required in download scenarios.
static internal void EnsureConfigLoaded() {
try {
//AuthenticationModules section
System.Net.AuthenticationManager.EnsureConfigLoaded();
//Requestcachingsection section
object o = System.Net.Cache.RequestCacheManager.IsCachingEnabled;
//ConnectionManagement section
o = System.Net.ServicePointManager.DefaultConnectionLimit;
//Settings section
o = System.Net.ServicePointManager.Expect100Continue;
//webrequestmodules section
o = System.Net.WebRequest.PrefixList;
//DefaultProxy section
o = System.Net.WebRequest.InternalDefaultWebProxy;
//perfcounters
NetworkingPerfCounters.Initialize();
}
catch {
}
}
public SettingsSection()
{
this.properties.Add(this.httpWebRequest);
this.properties.Add(this.ipv6);
this.properties.Add(this.servicePointManager);
this.properties.Add(this.socket);
this.properties.Add(this.webProxyScript);
this.properties.Add(this.performanceCounters);
}
[ConfigurationProperty(ConfigurationStrings.HttpWebRequest)]
public HttpWebRequestElement HttpWebRequest
{
get { return (HttpWebRequestElement)this[this.httpWebRequest]; }
}
[ConfigurationProperty(ConfigurationStrings.Ipv6)]
public Ipv6Element Ipv6
{
get { return (Ipv6Element)this[this.ipv6]; }
}
[ConfigurationProperty(ConfigurationStrings.ServicePointManager)]
public ServicePointManagerElement ServicePointManager
{
get { return (ServicePointManagerElement)this[this.servicePointManager]; }
}
[ConfigurationProperty(ConfigurationStrings.Socket)]
public SocketElement Socket
{
get { return (SocketElement)this[this.socket]; }
}
[ConfigurationProperty(ConfigurationStrings.WebProxyScript)]
public WebProxyScriptElement WebProxyScript
{
get { return (WebProxyScriptElement) this[this.webProxyScript]; }
}
[ConfigurationProperty(ConfigurationStrings.PerformanceCounters)]
public PerformanceCountersElement PerformanceCounters
{
get { return (PerformanceCountersElement) this[this.performanceCounters]; }
}
protected override ConfigurationPropertyCollection Properties
{
get { return this.properties; }
}
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
readonly ConfigurationProperty httpWebRequest =
new ConfigurationProperty(ConfigurationStrings.HttpWebRequest, typeof(HttpWebRequestElement), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty ipv6 =
new ConfigurationProperty(ConfigurationStrings.Ipv6, typeof(Ipv6Element), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty servicePointManager =
new ConfigurationProperty(ConfigurationStrings.ServicePointManager, typeof(ServicePointManagerElement), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty socket =
new ConfigurationProperty(ConfigurationStrings.Socket, typeof(SocketElement), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty webProxyScript =
new ConfigurationProperty(ConfigurationStrings.WebProxyScript, typeof(WebProxyScriptElement), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty performanceCounters =
new ConfigurationProperty(ConfigurationStrings.PerformanceCounters, typeof(PerformanceCountersElement), null,
ConfigurationPropertyOptions.None);
}
internal sealed class SettingsSectionInternal
{
private static object s_InternalSyncObject = null;
internal SettingsSectionInternal(SettingsSection section)
{
TimeSpan ts;
if (section == null)
section = new SettingsSection();
this.alwaysUseCompletionPortsForConnect = section.Socket.AlwaysUseCompletionPortsForConnect;
this.alwaysUseCompletionPortsForAccept = section.Socket.AlwaysUseCompletionPortsForAccept;
this.checkCertificateName = section.ServicePointManager.CheckCertificateName;
this.CheckCertificateRevocationList = section.ServicePointManager.CheckCertificateRevocationList;
this.DnsRefreshTimeout = section.ServicePointManager.DnsRefreshTimeout;
this.ipv6Enabled = section.Ipv6.Enabled;
this.EnableDnsRoundRobin = section.ServicePointManager.EnableDnsRoundRobin;
this.Expect100Continue = section.ServicePointManager.Expect100Continue;
this.maximumUnauthorizedUploadLength = section.HttpWebRequest.MaximumUnauthorizedUploadLength;
this.maximumResponseHeadersLength = section.HttpWebRequest.MaximumResponseHeadersLength;
this.maximumErrorResponseLength = section.HttpWebRequest.MaximumErrorResponseLength;
this.useUnsafeHeaderParsing = section.HttpWebRequest.UseUnsafeHeaderParsing;
this.UseNagleAlgorithm = section.ServicePointManager.UseNagleAlgorithm;
ts = section.WebProxyScript.DownloadTimeout;
this.downloadTimeout = (ts == TimeSpan.MaxValue || ts == TimeSpan.Zero) ? Timeout.Infinite : (int) ts.TotalMilliseconds;
/* Not used with Managed JScript
ts = section.WebProxyScript.ExecutionTimeout;
this.executionTimeout = (ts == TimeSpan.MaxValue || ts == TimeSpan.Zero) ? Timeout.Infinite : (int) ts.TotalMilliseconds;
*/
this.performanceCountersEnabled = section.PerformanceCounters.Enabled;
NetworkingPerfCounters.Initialize();
}
internal static SettingsSectionInternal Section
{
get
{
if (s_settings == null) {
lock(InternalSyncObject) {
if (s_settings == null) {
s_settings = new SettingsSectionInternal((SettingsSection) PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SettingsSectionPath));
}
}
}
return s_settings;
}
}
private static object InternalSyncObject {
get {
if (s_InternalSyncObject == null) {
object o = new object();
Interlocked.CompareExchange(ref s_InternalSyncObject, o, null);
}
return s_InternalSyncObject;
}
}
// This method is required - it gets called through reflection, matching all the other XxxSectionInternal classes.
// This one gets it fresh for each call. Generally it shouldn't be used.
internal static SettingsSectionInternal GetSection()
{
return new SettingsSectionInternal((SettingsSection) PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SettingsSectionPath));
}
internal bool AlwaysUseCompletionPortsForAccept
{
get { return this.alwaysUseCompletionPortsForAccept; }
}
internal bool AlwaysUseCompletionPortsForConnect
{
get { return this.alwaysUseCompletionPortsForConnect; }
}
internal bool CheckCertificateName
{
get { return this.checkCertificateName; }
}
internal bool CheckCertificateRevocationList
{
get { return this.checkCertificateRevocationList; }
set { this.checkCertificateRevocationList = value; }
}
internal int DnsRefreshTimeout
{
get { return this.dnsRefreshTimeout; }
set { this.dnsRefreshTimeout = value; }
}
internal int DownloadTimeout
{
get { return this.downloadTimeout; }
}
internal bool EnableDnsRoundRobin
{
get { return this.enableDnsRoundRobin; }
set { this.enableDnsRoundRobin = value; }
}
/* Not used with Managed JScript
internal int ExecutionTimeout
{
get { return this.executionTimeout; }
}
*/
internal bool Expect100Continue
{
get { return this.expect100Continue; }
set { this.expect100Continue = value; }
}
internal bool Ipv6Enabled
{
get { return this.ipv6Enabled; }
}
internal int MaximumResponseHeadersLength
{
get { return this.maximumResponseHeadersLength; }
set { this.maximumResponseHeadersLength = value; }
}
internal int MaximumUnauthorizedUploadLength
{
get { return this.maximumUnauthorizedUploadLength; }
/*
// Consider removing.
set { this.maximumUnauthorizedUploadLength = value; }
*/
}
internal int MaximumErrorResponseLength
{
get { return this.maximumErrorResponseLength; }
set { this.maximumErrorResponseLength = value; }
}
internal bool UseUnsafeHeaderParsing
{
get { return this.useUnsafeHeaderParsing; }
}
internal bool UseNagleAlgorithm
{
get { return this.useNagleAlgorithm; }
set { this.useNagleAlgorithm = value; }
}
internal bool PerformanceCountersEnabled
{
get { return this.performanceCountersEnabled; }
}
private static SettingsSectionInternal s_settings;
bool alwaysUseCompletionPortsForAccept;
bool alwaysUseCompletionPortsForConnect;
bool checkCertificateName;
bool checkCertificateRevocationList;
int downloadTimeout;
int dnsRefreshTimeout;
bool enableDnsRoundRobin;
/* Not used with Managed JScript
int executionTimeout;
*/
bool expect100Continue;
bool ipv6Enabled;
int maximumResponseHeadersLength;
int maximumErrorResponseLength;
int maximumUnauthorizedUploadLength;
bool useUnsafeHeaderParsing;
bool useNagleAlgorithm;
bool performanceCountersEnabled;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net.Configuration
{
using System.Configuration;
using System.Threading;
public sealed class SettingsSection : ConfigurationSection
{
// Placeholder for [....] to add code to load all configuration
// required in download scenarios.
static internal void EnsureConfigLoaded() {
try {
//AuthenticationModules section
System.Net.AuthenticationManager.EnsureConfigLoaded();
//Requestcachingsection section
object o = System.Net.Cache.RequestCacheManager.IsCachingEnabled;
//ConnectionManagement section
o = System.Net.ServicePointManager.DefaultConnectionLimit;
//Settings section
o = System.Net.ServicePointManager.Expect100Continue;
//webrequestmodules section
o = System.Net.WebRequest.PrefixList;
//DefaultProxy section
o = System.Net.WebRequest.InternalDefaultWebProxy;
//perfcounters
NetworkingPerfCounters.Initialize();
}
catch {
}
}
public SettingsSection()
{
this.properties.Add(this.httpWebRequest);
this.properties.Add(this.ipv6);
this.properties.Add(this.servicePointManager);
this.properties.Add(this.socket);
this.properties.Add(this.webProxyScript);
this.properties.Add(this.performanceCounters);
}
[ConfigurationProperty(ConfigurationStrings.HttpWebRequest)]
public HttpWebRequestElement HttpWebRequest
{
get { return (HttpWebRequestElement)this[this.httpWebRequest]; }
}
[ConfigurationProperty(ConfigurationStrings.Ipv6)]
public Ipv6Element Ipv6
{
get { return (Ipv6Element)this[this.ipv6]; }
}
[ConfigurationProperty(ConfigurationStrings.ServicePointManager)]
public ServicePointManagerElement ServicePointManager
{
get { return (ServicePointManagerElement)this[this.servicePointManager]; }
}
[ConfigurationProperty(ConfigurationStrings.Socket)]
public SocketElement Socket
{
get { return (SocketElement)this[this.socket]; }
}
[ConfigurationProperty(ConfigurationStrings.WebProxyScript)]
public WebProxyScriptElement WebProxyScript
{
get { return (WebProxyScriptElement) this[this.webProxyScript]; }
}
[ConfigurationProperty(ConfigurationStrings.PerformanceCounters)]
public PerformanceCountersElement PerformanceCounters
{
get { return (PerformanceCountersElement) this[this.performanceCounters]; }
}
protected override ConfigurationPropertyCollection Properties
{
get { return this.properties; }
}
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
readonly ConfigurationProperty httpWebRequest =
new ConfigurationProperty(ConfigurationStrings.HttpWebRequest, typeof(HttpWebRequestElement), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty ipv6 =
new ConfigurationProperty(ConfigurationStrings.Ipv6, typeof(Ipv6Element), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty servicePointManager =
new ConfigurationProperty(ConfigurationStrings.ServicePointManager, typeof(ServicePointManagerElement), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty socket =
new ConfigurationProperty(ConfigurationStrings.Socket, typeof(SocketElement), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty webProxyScript =
new ConfigurationProperty(ConfigurationStrings.WebProxyScript, typeof(WebProxyScriptElement), null,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty performanceCounters =
new ConfigurationProperty(ConfigurationStrings.PerformanceCounters, typeof(PerformanceCountersElement), null,
ConfigurationPropertyOptions.None);
}
internal sealed class SettingsSectionInternal
{
private static object s_InternalSyncObject = null;
internal SettingsSectionInternal(SettingsSection section)
{
TimeSpan ts;
if (section == null)
section = new SettingsSection();
this.alwaysUseCompletionPortsForConnect = section.Socket.AlwaysUseCompletionPortsForConnect;
this.alwaysUseCompletionPortsForAccept = section.Socket.AlwaysUseCompletionPortsForAccept;
this.checkCertificateName = section.ServicePointManager.CheckCertificateName;
this.CheckCertificateRevocationList = section.ServicePointManager.CheckCertificateRevocationList;
this.DnsRefreshTimeout = section.ServicePointManager.DnsRefreshTimeout;
this.ipv6Enabled = section.Ipv6.Enabled;
this.EnableDnsRoundRobin = section.ServicePointManager.EnableDnsRoundRobin;
this.Expect100Continue = section.ServicePointManager.Expect100Continue;
this.maximumUnauthorizedUploadLength = section.HttpWebRequest.MaximumUnauthorizedUploadLength;
this.maximumResponseHeadersLength = section.HttpWebRequest.MaximumResponseHeadersLength;
this.maximumErrorResponseLength = section.HttpWebRequest.MaximumErrorResponseLength;
this.useUnsafeHeaderParsing = section.HttpWebRequest.UseUnsafeHeaderParsing;
this.UseNagleAlgorithm = section.ServicePointManager.UseNagleAlgorithm;
ts = section.WebProxyScript.DownloadTimeout;
this.downloadTimeout = (ts == TimeSpan.MaxValue || ts == TimeSpan.Zero) ? Timeout.Infinite : (int) ts.TotalMilliseconds;
/* Not used with Managed JScript
ts = section.WebProxyScript.ExecutionTimeout;
this.executionTimeout = (ts == TimeSpan.MaxValue || ts == TimeSpan.Zero) ? Timeout.Infinite : (int) ts.TotalMilliseconds;
*/
this.performanceCountersEnabled = section.PerformanceCounters.Enabled;
NetworkingPerfCounters.Initialize();
}
internal static SettingsSectionInternal Section
{
get
{
if (s_settings == null) {
lock(InternalSyncObject) {
if (s_settings == null) {
s_settings = new SettingsSectionInternal((SettingsSection) PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SettingsSectionPath));
}
}
}
return s_settings;
}
}
private static object InternalSyncObject {
get {
if (s_InternalSyncObject == null) {
object o = new object();
Interlocked.CompareExchange(ref s_InternalSyncObject, o, null);
}
return s_InternalSyncObject;
}
}
// This method is required - it gets called through reflection, matching all the other XxxSectionInternal classes.
// This one gets it fresh for each call. Generally it shouldn't be used.
internal static SettingsSectionInternal GetSection()
{
return new SettingsSectionInternal((SettingsSection) PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SettingsSectionPath));
}
internal bool AlwaysUseCompletionPortsForAccept
{
get { return this.alwaysUseCompletionPortsForAccept; }
}
internal bool AlwaysUseCompletionPortsForConnect
{
get { return this.alwaysUseCompletionPortsForConnect; }
}
internal bool CheckCertificateName
{
get { return this.checkCertificateName; }
}
internal bool CheckCertificateRevocationList
{
get { return this.checkCertificateRevocationList; }
set { this.checkCertificateRevocationList = value; }
}
internal int DnsRefreshTimeout
{
get { return this.dnsRefreshTimeout; }
set { this.dnsRefreshTimeout = value; }
}
internal int DownloadTimeout
{
get { return this.downloadTimeout; }
}
internal bool EnableDnsRoundRobin
{
get { return this.enableDnsRoundRobin; }
set { this.enableDnsRoundRobin = value; }
}
/* Not used with Managed JScript
internal int ExecutionTimeout
{
get { return this.executionTimeout; }
}
*/
internal bool Expect100Continue
{
get { return this.expect100Continue; }
set { this.expect100Continue = value; }
}
internal bool Ipv6Enabled
{
get { return this.ipv6Enabled; }
}
internal int MaximumResponseHeadersLength
{
get { return this.maximumResponseHeadersLength; }
set { this.maximumResponseHeadersLength = value; }
}
internal int MaximumUnauthorizedUploadLength
{
get { return this.maximumUnauthorizedUploadLength; }
/*
// Consider removing.
set { this.maximumUnauthorizedUploadLength = value; }
*/
}
internal int MaximumErrorResponseLength
{
get { return this.maximumErrorResponseLength; }
set { this.maximumErrorResponseLength = value; }
}
internal bool UseUnsafeHeaderParsing
{
get { return this.useUnsafeHeaderParsing; }
}
internal bool UseNagleAlgorithm
{
get { return this.useNagleAlgorithm; }
set { this.useNagleAlgorithm = value; }
}
internal bool PerformanceCountersEnabled
{
get { return this.performanceCountersEnabled; }
}
private static SettingsSectionInternal s_settings;
bool alwaysUseCompletionPortsForAccept;
bool alwaysUseCompletionPortsForConnect;
bool checkCertificateName;
bool checkCertificateRevocationList;
int downloadTimeout;
int dnsRefreshTimeout;
bool enableDnsRoundRobin;
/* Not used with Managed JScript
int executionTimeout;
*/
bool expect100Continue;
bool ipv6Enabled;
int maximumResponseHeadersLength;
int maximumErrorResponseLength;
int maximumUnauthorizedUploadLength;
bool useUnsafeHeaderParsing;
bool useNagleAlgorithm;
bool performanceCountersEnabled;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebEventTraceProvider.cs
- KeyValueSerializer.cs
- XPathDocumentBuilder.cs
- CharEntityEncoderFallback.cs
- ClientBuildManagerCallback.cs
- Context.cs
- FrameworkName.cs
- CompositeCollection.cs
- CalendarDay.cs
- BamlLocalizableResourceKey.cs
- SharedPersonalizationStateInfo.cs
- AnnotationStore.cs
- RecommendedAsConfigurableAttribute.cs
- Executor.cs
- ImageConverter.cs
- SQLBinary.cs
- DependencyProperty.cs
- XmlSignificantWhitespace.cs
- DrawingState.cs
- XmlAnyElementAttribute.cs
- PartManifestEntry.cs
- EDesignUtil.cs
- SizeConverter.cs
- LineGeometry.cs
- HistoryEventArgs.cs
- TraceHandlerErrorFormatter.cs
- MDIWindowDialog.cs
- Resources.Designer.cs
- SizeF.cs
- SqlDataReader.cs
- ClientRuntimeConfig.cs
- BehaviorDragDropEventArgs.cs
- RSAOAEPKeyExchangeDeformatter.cs
- AsymmetricAlgorithm.cs
- InternalException.cs
- QilReference.cs
- MissingMemberException.cs
- WebUtil.cs
- CheckBoxField.cs
- ConcurrentQueue.cs
- XmlBinaryWriterSession.cs
- AutomationProperty.cs
- Brush.cs
- MethodSet.cs
- GlobalizationSection.cs
- EventBindingService.cs
- WmpBitmapEncoder.cs
- HtmlMobileTextWriter.cs
- PathFigureCollection.cs
- CopyCodeAction.cs
- TableLayoutPanelCellPosition.cs
- PreloadedPackages.cs
- KnownBoxes.cs
- Win32.cs
- BinaryFormatterWriter.cs
- ResXResourceReader.cs
- SocketException.cs
- MouseGesture.cs
- TdsValueSetter.cs
- X509CertificateCollection.cs
- DockPanel.cs
- XmlAttributes.cs
- BitStack.cs
- LinkLabel.cs
- Comparer.cs
- LongValidator.cs
- DefaultParameterValueAttribute.cs
- StylusButton.cs
- DrawingImage.cs
- RequiredFieldValidator.cs
- ISAPIWorkerRequest.cs
- SuppressIldasmAttribute.cs
- Int32CollectionValueSerializer.cs
- __Error.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- Point3DAnimationBase.cs
- ContentPlaceHolder.cs
- ResourceExpressionBuilder.cs
- FlowPosition.cs
- XmlNodeReader.cs
- CustomError.cs
- SystemException.cs
- Psha1DerivedKeyGenerator.cs
- BuilderElements.cs
- ManagedFilter.cs
- RelationshipFixer.cs
- GlyphElement.cs
- Logging.cs
- InkCanvasInnerCanvas.cs
- UriSectionReader.cs
- CallbackTimeoutsElement.cs
- SoapObjectReader.cs
- ReaderWriterLock.cs
- SiteMapNodeItem.cs
- StorageFunctionMapping.cs
- SystemDiagnosticsSection.cs
- Int16Storage.cs
- CollectionDataContractAttribute.cs
- MultiDataTrigger.cs
- UInt32Storage.cs