Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / Configuration / WebRequestModulesSection.cs / 1 / WebRequestModulesSection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net.Configuration
{
using System.Configuration;
using System.Collections;
using System.Globalization;
using System.Net;
using System.Reflection;
using System.Threading;
public sealed class WebRequestModulesSection : ConfigurationSection
{
public WebRequestModulesSection()
{
this.properties.Add(this.webRequestModules);
}
protected override void PostDeserialize()
{
// Perf optimization. If the configuration is coming from machine.config
// It is safe and we don't need to check for permissions.
if (EvaluationContext.IsMachineLevel)
return;
try {
ExceptionHelper.WebPermissionUnrestricted.Demand();
} catch (Exception exception) {
throw new ConfigurationErrorsException(
SR.GetString(SR.net_config_section_permission,
ConfigurationStrings.WebRequestModulesSectionName),
exception);
}
}
protected override void InitializeDefault()
{
this.WebRequestModules.Add(
new WebRequestModuleElement(ConfigurationStrings.Https, typeof(HttpRequestCreator)));
this.WebRequestModules.Add(
new WebRequestModuleElement(ConfigurationStrings.Http, typeof(HttpRequestCreator)));
this.WebRequestModules.Add(
new WebRequestModuleElement(ConfigurationStrings.File, typeof(FileWebRequestCreator)));
this.WebRequestModules.Add(
new WebRequestModuleElement(ConfigurationStrings.Ftp, typeof(FtpWebRequestCreator)));
}
protected override ConfigurationPropertyCollection Properties
{
get { return this.properties; }
}
[ConfigurationProperty("", IsDefaultCollection=true )]
public WebRequestModuleElementCollection WebRequestModules
{
get { return (WebRequestModuleElementCollection)this[this.webRequestModules]; }
}
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
readonly ConfigurationProperty webRequestModules =
new ConfigurationProperty(null, typeof(WebRequestModuleElementCollection), null,
ConfigurationPropertyOptions.IsDefaultCollection);
}
internal sealed class WebRequestModulesSectionInternal
{
internal WebRequestModulesSectionInternal(WebRequestModulesSection section)
{
if (section.WebRequestModules.Count > 0)
{
this.webRequestModules = new ArrayList(section.WebRequestModules.Count);
foreach(WebRequestModuleElement webRequestModuleElement in section.WebRequestModules)
{
try
{
this.webRequestModules.Add(new WebRequestPrefixElement(webRequestModuleElement.Prefix, webRequestModuleElement.Type));
}
catch (Exception exception)
{
if (NclUtilities.IsFatal(exception)) throw;
throw new ConfigurationErrorsException(SR.GetString(SR.net_config_webrequestmodules), exception);
}
catch {
//
// throw exception for config debugging
//
throw new ConfigurationErrorsException(ConfigurationStrings.WebRequestModulesSectionPath, new Exception(SR.GetString(SR.net_nonClsCompliantException)));
}
}
}
}
internal static object ClassSyncObject
{
get
{
if (classSyncObject == null)
{
object o = new object();
Interlocked.CompareExchange(ref classSyncObject, o, null);
}
return classSyncObject;
}
}
static internal WebRequestModulesSectionInternal GetSection()
{
lock (WebRequestModulesSectionInternal.ClassSyncObject)
{
WebRequestModulesSection section = PrivilegedConfigurationManager.GetSection(ConfigurationStrings.WebRequestModulesSectionPath) as WebRequestModulesSection;
if (section == null)
return null;
return new WebRequestModulesSectionInternal(section);
}
}
internal ArrayList WebRequestModules
{
get
{
ArrayList retval = this.webRequestModules;
if (retval == null)
{
retval = new ArrayList(0);
}
return retval;
}
}
static object classSyncObject = null;
ArrayList webRequestModules = null;
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProxyElement.cs
- MouseEvent.cs
- LockRecursionException.cs
- ConfigurationSectionGroupCollection.cs
- URLMembershipCondition.cs
- XamlFigureLengthSerializer.cs
- StrokeNodeEnumerator.cs
- RelatedImageListAttribute.cs
- Helpers.cs
- XmlnsDictionary.cs
- DeflateStream.cs
- ResourceWriter.cs
- DragStartedEventArgs.cs
- ItemCollectionEditor.cs
- AcceleratedTokenProvider.cs
- PrimitiveXmlSerializers.cs
- ObjectConverter.cs
- ShimAsPublicXamlType.cs
- MaterialGroup.cs
- FunctionUpdateCommand.cs
- StrokeIntersection.cs
- DbXmlEnabledProviderManifest.cs
- BrowserDefinitionCollection.cs
- TypeExtensions.cs
- ValueTypeFixupInfo.cs
- HostingEnvironmentSection.cs
- IDispatchConstantAttribute.cs
- AuthenticateEventArgs.cs
- DefaultAssemblyResolver.cs
- IgnoreFileBuildProvider.cs
- Encoder.cs
- PolicyLevel.cs
- Base64Encoder.cs
- ExpandCollapseIsCheckedConverter.cs
- TargetFrameworkAttribute.cs
- TransformerTypeCollection.cs
- TriggerActionCollection.cs
- DataGridGeneralPage.cs
- DefaultPropertyAttribute.cs
- Scheduler.cs
- TheQuery.cs
- WindowsFont.cs
- ConfigXmlCDataSection.cs
- ADMembershipUser.cs
- Popup.cs
- MobileTextWriter.cs
- ReadContentAsBinaryHelper.cs
- MasterPageBuildProvider.cs
- FragmentQueryKB.cs
- BinaryFormatterWriter.cs
- HybridDictionary.cs
- RuntimeCompatibilityAttribute.cs
- UTF32Encoding.cs
- RemoteArgument.cs
- BlockCollection.cs
- FlowDocumentScrollViewer.cs
- Publisher.cs
- CapabilitiesState.cs
- SymbolDocumentInfo.cs
- GraphicsPath.cs
- HttpCacheVaryByContentEncodings.cs
- CheckBoxFlatAdapter.cs
- _FtpControlStream.cs
- ToolStripGrip.cs
- AnnotationService.cs
- ListenerServiceInstallComponent.cs
- ECDsaCng.cs
- DataKeyArray.cs
- InvokeMethodActivity.cs
- ContextStaticAttribute.cs
- Buffer.cs
- ConfigurationSectionHelper.cs
- WindowsTokenRoleProvider.cs
- TabControl.cs
- Annotation.cs
- InvalidCommandTreeException.cs
- ScriptingRoleServiceSection.cs
- PlaceHolder.cs
- SByteConverter.cs
- MemoryRecordBuffer.cs
- Merger.cs
- InternalCache.cs
- DecimalAnimationUsingKeyFrames.cs
- PipelineModuleStepContainer.cs
- ItemsChangedEventArgs.cs
- ImportOptions.cs
- WebServiceParameterData.cs
- TableLayoutStyleCollection.cs
- _HeaderInfoTable.cs
- ResourceDescriptionAttribute.cs
- FontFamily.cs
- SID.cs
- FontCacheLogic.cs
- ZipIOLocalFileDataDescriptor.cs
- WindowsPrincipal.cs
- XmlDataFileEditor.cs
- PathNode.cs
- BooleanFunctions.cs
- DomainConstraint.cs
- PersonalizationState.cs