Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- SpeechRecognitionEngine.cs
- CrossSiteScriptingValidation.cs
- HttpGetClientProtocol.cs
- RadioButtonRenderer.cs
- CopyNamespacesAction.cs
- FormParameter.cs
- WebScriptServiceHost.cs
- XPathAncestorQuery.cs
- SmtpLoginAuthenticationModule.cs
- BaseDataBoundControl.cs
- AnimatedTypeHelpers.cs
- VideoDrawing.cs
- figurelength.cs
- MarkupExtensionSerializer.cs
- CharAnimationUsingKeyFrames.cs
- BamlBinaryWriter.cs
- TextParaLineResult.cs
- MembershipSection.cs
- AgileSafeNativeMemoryHandle.cs
- SqlMethodAttribute.cs
- SetUserLanguageRequest.cs
- LinkTarget.cs
- SyntaxCheck.cs
- MessageBodyMemberAttribute.cs
- Common.cs
- InputReferenceExpression.cs
- DbProviderSpecificTypePropertyAttribute.cs
- PeerName.cs
- SafeLibraryHandle.cs
- NotImplementedException.cs
- BindingMAnagerBase.cs
- SpecialNameAttribute.cs
- SqlDataSourceCache.cs
- HostVisual.cs
- SchemaInfo.cs
- GlyphInfoList.cs
- CustomTypeDescriptor.cs
- Vertex.cs
- StreamUpdate.cs
- RegexRunnerFactory.cs
- SqlEnums.cs
- ContentValidator.cs
- AppSettingsReader.cs
- DefaultAsyncDataDispatcher.cs
- XPathExpr.cs
- EdmError.cs
- ContentHostHelper.cs
- input.cs
- URLAttribute.cs
- ConnectionInterfaceCollection.cs
- TextProviderWrapper.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- GuidConverter.cs
- ToolStripPanelRow.cs
- InputLanguage.cs
- BindingList.cs
- ImmutableObjectAttribute.cs
- MemberMaps.cs
- BinaryCommonClasses.cs
- TypeInfo.cs
- IdentityModelStringsVersion1.cs
- CodeMemberProperty.cs
- WebPartDisplayMode.cs
- SimpleLine.cs
- BehaviorEditorPart.cs
- securitycriticaldataformultiplegetandset.cs
- AppDomainProtocolHandler.cs
- MemoryStream.cs
- DataServiceCollectionOfT.cs
- DependencyPropertyHelper.cs
- _AuthenticationState.cs
- TrustLevelCollection.cs
- PrintDocument.cs
- CompoundFileDeflateTransform.cs
- Msec.cs
- ThreadTrace.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- ListViewItemEventArgs.cs
- DataViewManager.cs
- Trace.cs
- GridViewEditEventArgs.cs
- ApplicationFileParser.cs
- IChannel.cs
- ExeConfigurationFileMap.cs
- ContainerVisual.cs
- FloatAverageAggregationOperator.cs
- Compiler.cs
- Operator.cs
- QilTypeChecker.cs
- ScalarConstant.cs
- CellIdBoolean.cs
- Convert.cs
- FileDetails.cs
- WorkItem.cs
- FrameworkElementFactoryMarkupObject.cs
- OdbcException.cs
- SimplePropertyEntry.cs
- CodeDomExtensionMethods.cs
- WebBrowserProgressChangedEventHandler.cs
- LockCookie.cs