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
- ConfigDefinitionUpdates.cs
- CommandBinding.cs
- BoundPropertyEntry.cs
- PrtCap_Public_Simple.cs
- DbParameterCollectionHelper.cs
- CursorConverter.cs
- ProviderConnectionPointCollection.cs
- DeleteIndexBinder.cs
- CssTextWriter.cs
- ClientRuntimeConfig.cs
- BooleanExpr.cs
- TransformPatternIdentifiers.cs
- SqlCommandAsyncResult.cs
- DataProtection.cs
- OleDbException.cs
- TextElementEnumerator.cs
- ScriptingProfileServiceSection.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- BitmapInitialize.cs
- DesignBindingConverter.cs
- OperatingSystem.cs
- WebPermission.cs
- ResourceBinder.cs
- Rect3D.cs
- RtfNavigator.cs
- CollectionConverter.cs
- MeasureData.cs
- InstanceStoreQueryResult.cs
- PasswordRecovery.cs
- ListMarkerLine.cs
- webproxy.cs
- ColorMatrix.cs
- GeometryCombineModeValidation.cs
- MemberAccessException.cs
- HtmlInputButton.cs
- EventLogPermissionEntryCollection.cs
- FocusManager.cs
- ThemeConfigurationDialog.cs
- IconBitmapDecoder.cs
- ToolStripManager.cs
- RadioButtonList.cs
- XmlEntity.cs
- SafeRightsManagementEnvironmentHandle.cs
- DataSourceSelectArguments.cs
- DataGridViewTopLeftHeaderCell.cs
- CommandField.cs
- SelectedDatesCollection.cs
- FixedPageAutomationPeer.cs
- BaseTemplateCodeDomTreeGenerator.cs
- CharEnumerator.cs
- ViewStateException.cs
- XmlCharCheckingWriter.cs
- Matrix3DStack.cs
- RelatedImageListAttribute.cs
- BindingSource.cs
- TextProperties.cs
- MetafileHeaderEmf.cs
- OutputCacheSettings.cs
- Size3DValueSerializer.cs
- PeerUnsafeNativeCryptMethods.cs
- ConfigurationElementProperty.cs
- XmlSchemaExternal.cs
- BinHexEncoder.cs
- AuthenticateEventArgs.cs
- FormViewDeletedEventArgs.cs
- ProgressBarAutomationPeer.cs
- SamlDelegatingWriter.cs
- PackageProperties.cs
- IntSecurity.cs
- PolyLineSegmentFigureLogic.cs
- __TransparentProxy.cs
- ViewStateException.cs
- HybridDictionary.cs
- StackBuilderSink.cs
- X500Name.cs
- RoutedEventConverter.cs
- QuaternionAnimation.cs
- FlowDocumentFormatter.cs
- DebugController.cs
- PageParser.cs
- CustomExpression.cs
- TableLayoutStyle.cs
- sqlnorm.cs
- ToolboxComponentsCreatedEventArgs.cs
- GridViewCancelEditEventArgs.cs
- GenerateScriptTypeAttribute.cs
- ListViewAutomationPeer.cs
- MemberPath.cs
- LinqDataSource.cs
- HScrollProperties.cs
- InternalControlCollection.cs
- ComPlusThreadInitializer.cs
- LocalTransaction.cs
- SortDescriptionCollection.cs
- XmlWrappingReader.cs
- KeyedHashAlgorithm.cs
- AuthorizationRuleCollection.cs
- CodeDirectoryCompiler.cs
- MenuItem.cs
- EntityClassGenerator.cs