Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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; } } // 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.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; } } // 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
- DetailsViewModeEventArgs.cs
- FormViewRow.cs
- QilValidationVisitor.cs
- ExtensibleClassFactory.cs
- WebPartTransformer.cs
- DbBuffer.cs
- XmlWriterTraceListener.cs
- WindowsFormsHelpers.cs
- Vector3dCollection.cs
- ServiceAuthorizationElement.cs
- XmlSchemaAttributeGroupRef.cs
- XmlMemberMapping.cs
- ScrollableControlDesigner.cs
- StateMachineDesignerPaint.cs
- DrawingState.cs
- Empty.cs
- ImageCodecInfo.cs
- ContextMenuService.cs
- CollectionBase.cs
- InvokeHandlers.cs
- WrapPanel.cs
- HtmlMobileTextWriter.cs
- WebSysDefaultValueAttribute.cs
- MD5Cng.cs
- HttpListenerResponse.cs
- PersonalizationStateInfo.cs
- HwndMouseInputProvider.cs
- FlowDocumentReader.cs
- LookupNode.cs
- FontNamesConverter.cs
- StrongNameUtility.cs
- EntityProviderFactory.cs
- PropertyPath.cs
- ProcessModelSection.cs
- ColorMap.cs
- DataGridrowEditEndingEventArgs.cs
- NameValueConfigurationCollection.cs
- FormConverter.cs
- ConstructorNeedsTagAttribute.cs
- ReliabilityContractAttribute.cs
- PathHelper.cs
- BinaryObjectReader.cs
- IndentTextWriter.cs
- DbCommandTree.cs
- SessionEndedEventArgs.cs
- StylusPointProperties.cs
- UpWmlPageAdapter.cs
- initElementDictionary.cs
- CodeParameterDeclarationExpression.cs
- RectKeyFrameCollection.cs
- smtpconnection.cs
- RadioButtonAutomationPeer.cs
- ColorComboBox.cs
- RemotingServices.cs
- WebPartMenu.cs
- ChangeProcessor.cs
- FormViewInsertedEventArgs.cs
- Item.cs
- Int64.cs
- _SslState.cs
- SapiRecoInterop.cs
- WsatServiceAddress.cs
- ColorTransformHelper.cs
- InvalidProgramException.cs
- TypeDependencyAttribute.cs
- EntityContainerEmitter.cs
- ProtectedConfiguration.cs
- AttachedPropertyMethodSelector.cs
- MimeTypeAttribute.cs
- Button.cs
- NavigationFailedEventArgs.cs
- Renderer.cs
- StringSorter.cs
- PLINQETWProvider.cs
- WebPartMenu.cs
- CodeChecksumPragma.cs
- SmiXetterAccessMap.cs
- SqlDeflator.cs
- wmiprovider.cs
- XmlILAnnotation.cs
- CompositeScriptReference.cs
- SocketException.cs
- SocketPermission.cs
- ProfileSection.cs
- JsonFormatWriterGenerator.cs
- VectorAnimationUsingKeyFrames.cs
- NumericUpDownAccelerationCollection.cs
- WebContext.cs
- GroupStyle.cs
- DataGridAddNewRow.cs
- TextElementCollectionHelper.cs
- _AcceptOverlappedAsyncResult.cs
- TypeSystemHelpers.cs
- SimpleHandlerFactory.cs
- UIAgentMonitor.cs
- ExceptionDetail.cs
- EllipticalNodeOperations.cs
- UInt64.cs
- PenCursorManager.cs
- ConfigUtil.cs