Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- CardSpacePolicyElement.cs
- EntityDesignerDataSourceView.cs
- MobileTextWriter.cs
- LiteralControl.cs
- RotateTransform3D.cs
- TimerElapsedEvenArgs.cs
- AbstractExpressions.cs
- RequiredAttributeAttribute.cs
- AnyAllSearchOperator.cs
- ReflectionServiceProvider.cs
- ExtendedProperty.cs
- Package.cs
- IRCollection.cs
- XPathSelectionIterator.cs
- XmlNodeList.cs
- DataPagerFieldCommandEventArgs.cs
- StateWorkerRequest.cs
- SoapCodeExporter.cs
- TypeForwardedFromAttribute.cs
- HttpStreams.cs
- WrapperEqualityComparer.cs
- DesignerActionGlyph.cs
- ISCIIEncoding.cs
- KnownColorTable.cs
- DecimalAnimation.cs
- InvokeMethodActivity.cs
- XmlObjectSerializerWriteContextComplex.cs
- XhtmlTextWriter.cs
- DispatchWrapper.cs
- ConfigXmlElement.cs
- IntSecurity.cs
- X509SecurityTokenProvider.cs
- TypeResolvingOptions.cs
- ExceptionUtil.cs
- ResizeBehavior.cs
- CodeIndexerExpression.cs
- TypeSystem.cs
- FormsAuthentication.cs
- ReaderWriterLock.cs
- NotFiniteNumberException.cs
- SoapCodeExporter.cs
- DataObjectEventArgs.cs
- FacetDescriptionElement.cs
- ControlPaint.cs
- XamlClipboardData.cs
- SettingsAttributeDictionary.cs
- CalloutQueueItem.cs
- WebPartChrome.cs
- BinaryCommonClasses.cs
- MimeTypePropertyAttribute.cs
- DataTableNewRowEvent.cs
- StateItem.cs
- ConfigurationValidatorAttribute.cs
- FileUpload.cs
- ItemCheckedEvent.cs
- ToolStripPanelCell.cs
- RadioButtonPopupAdapter.cs
- MyContact.cs
- NodeFunctions.cs
- ValidationHelper.cs
- DataFormats.cs
- CommandDevice.cs
- SoapExtensionImporter.cs
- GetFileNameResult.cs
- PrimitiveType.cs
- StorageInfo.cs
- SoapWriter.cs
- UnmanagedMemoryAccessor.cs
- StylusEventArgs.cs
- odbcmetadatafactory.cs
- TrackBarRenderer.cs
- WebScriptMetadataMessage.cs
- RectangleF.cs
- UriTemplateMatch.cs
- PositiveTimeSpanValidator.cs
- DocumentGridPage.cs
- TextEndOfSegment.cs
- ProfilePropertyMetadata.cs
- ContainerActivationHelper.cs
- DataGridCommandEventArgs.cs
- AccessedThroughPropertyAttribute.cs
- BackEase.cs
- GPRECTF.cs
- EntityViewContainer.cs
- InkCanvasSelectionAdorner.cs
- PasswordRecoveryAutoFormat.cs
- HttpGetProtocolImporter.cs
- FontWeights.cs
- FaultReason.cs
- DynamicRendererThreadManager.cs
- NativeRightsManagementAPIsStructures.cs
- ZoneButton.cs
- ELinqQueryState.cs
- CategoryNameCollection.cs
- DataControlButton.cs
- PersonalizableTypeEntry.cs
- FileUpload.cs
- TableSectionStyle.cs
- CryptoKeySecurity.cs
- DefaultValueMapping.cs