Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Configuration / WebRequestModulesSection.cs / 1305376 / 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); } } } } 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); } } } } 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
- BindingContext.cs
- DataShape.cs
- NodeCounter.cs
- TargetException.cs
- glyphs.cs
- AnimationTimeline.cs
- DataGridItem.cs
- FormsAuthenticationEventArgs.cs
- EntityContainerEntitySetDefiningQuery.cs
- InvariantComparer.cs
- ThicknessConverter.cs
- MouseButton.cs
- EdmRelationshipRoleAttribute.cs
- UrlAuthFailedErrorFormatter.cs
- FamilyCollection.cs
- Bezier.cs
- TextProperties.cs
- WebBrowsableAttribute.cs
- PrintingPermissionAttribute.cs
- WebPartMinimizeVerb.cs
- ViewRendering.cs
- Function.cs
- PropagatorResult.cs
- IndexedString.cs
- VariableQuery.cs
- QuaternionRotation3D.cs
- JsonFormatWriterGenerator.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- CacheOutputQuery.cs
- ValidatingReaderNodeData.cs
- CanonicalXml.cs
- KeyValueConfigurationElement.cs
- MetabaseServerConfig.cs
- OleDbFactory.cs
- HandlerBase.cs
- TreeBuilder.cs
- LocalizedNameDescriptionPair.cs
- CompareInfo.cs
- SortedList.cs
- PropertyMapper.cs
- COAUTHINFO.cs
- HttpHandler.cs
- GeneralTransform2DTo3DTo2D.cs
- TableCell.cs
- Transform3DGroup.cs
- ApplicationException.cs
- TimeoutException.cs
- HtmlInputSubmit.cs
- ErrorWrapper.cs
- BinaryOperationBinder.cs
- XamlStyleSerializer.cs
- DbUpdateCommandTree.cs
- DataGridDetailsPresenterAutomationPeer.cs
- PeerApplicationLaunchInfo.cs
- smtppermission.cs
- EmbossBitmapEffect.cs
- IODescriptionAttribute.cs
- SelectionGlyph.cs
- StyleHelper.cs
- TextServicesProperty.cs
- OperatingSystemVersionCheck.cs
- WindowsListViewSubItem.cs
- WebServiceData.cs
- ChildTable.cs
- LinqDataSourceContextEventArgs.cs
- PostBackOptions.cs
- EllipseGeometry.cs
- FormatterConverter.cs
- Int64Storage.cs
- DesignerActionGlyph.cs
- SecurityTokenSerializer.cs
- XPathQilFactory.cs
- Expressions.cs
- CultureSpecificStringDictionary.cs
- TrackBar.cs
- SwitchElementsCollection.cs
- fixedPageContentExtractor.cs
- FormViewActionList.cs
- WindowsListViewItemCheckBox.cs
- BrowsableAttribute.cs
- HighContrastHelper.cs
- BindingValueChangedEventArgs.cs
- TextSegment.cs
- webbrowsersite.cs
- CharUnicodeInfo.cs
- TypeLoadException.cs
- RuntimeHandles.cs
- QueryableDataSource.cs
- RenderDataDrawingContext.cs
- Themes.cs
- DataServiceExpressionVisitor.cs
- PanelDesigner.cs
- RequestSecurityTokenForGetBrowserToken.cs
- COAUTHIDENTITY.cs
- AutoResetEvent.cs
- DiscoveryMessageSequence11.cs
- PeerEndPoint.cs
- ContentAlignmentEditor.cs
- DoubleCollectionConverter.cs
- EventDrivenDesigner.cs