Code:
/ DotNET / DotNET / 8.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
- Unit.cs
- AnnotationStore.cs
- InvalidComObjectException.cs
- CanonicalFontFamilyReference.cs
- RegistryKey.cs
- SessionStateSection.cs
- TranslateTransform.cs
- HtmlInputSubmit.cs
- MetadataItem.cs
- GeneralTransform3DGroup.cs
- ServiceNameCollection.cs
- ToolBarButton.cs
- GlyphingCache.cs
- FrameDimension.cs
- Clipboard.cs
- documentsequencetextview.cs
- ContextQuery.cs
- UmAlQuraCalendar.cs
- PageHandlerFactory.cs
- ToolStripItemGlyph.cs
- MessageQueueCriteria.cs
- XomlCompiler.cs
- BoolExpression.cs
- SqlMethodCallConverter.cs
- Token.cs
- XmlStreamStore.cs
- MetadataItemSerializer.cs
- DbConnectionPoolOptions.cs
- MD5HashHelper.cs
- EntityStoreSchemaFilterEntry.cs
- ResourceProviderFactory.cs
- XDRSchema.cs
- DynamicDiscoSearcher.cs
- ResourceLoader.cs
- SqlCommandSet.cs
- DocumentViewerBaseAutomationPeer.cs
- WizardDesigner.cs
- BinaryNode.cs
- XPathBinder.cs
- RepeaterCommandEventArgs.cs
- MtomMessageEncoder.cs
- XmlReaderSettings.cs
- TableItemPattern.cs
- XmlIlTypeHelper.cs
- ClipboardProcessor.cs
- EDesignUtil.cs
- ResourceReferenceExpressionConverter.cs
- TextAction.cs
- PublisherIdentityPermission.cs
- PageOutputQuality.cs
- DayRenderEvent.cs
- InvalidEnumArgumentException.cs
- SamlSecurityTokenAuthenticator.cs
- ContextMarshalException.cs
- FileSystemInfo.cs
- StringConcat.cs
- InstancePersistenceCommand.cs
- ListMarkerLine.cs
- ActivationArguments.cs
- FixedSOMSemanticBox.cs
- Logging.cs
- DynamicPropertyHolder.cs
- QualifiedCellIdBoolean.cs
- SendContent.cs
- SiteIdentityPermission.cs
- ContentValidator.cs
- HostedImpersonationContext.cs
- LexicalChunk.cs
- MatrixKeyFrameCollection.cs
- AutoScrollExpandMessageFilter.cs
- ContractMapping.cs
- LogEntryHeaderv1Deserializer.cs
- NotFiniteNumberException.cs
- PenThread.cs
- Odbc32.cs
- FileIOPermission.cs
- BlockingCollection.cs
- XmlSerializerSection.cs
- CodeBlockBuilder.cs
- BaseContextMenu.cs
- DynamicMetaObject.cs
- OracleBoolean.cs
- CodeCatchClauseCollection.cs
- WithParamAction.cs
- ProgressBar.cs
- QualifiedId.cs
- HeaderedContentControl.cs
- PolicyStatement.cs
- HyperLinkStyle.cs
- Mouse.cs
- CaseStatement.cs
- SerializationException.cs
- SafeHandle.cs
- SimpleBitVector32.cs
- DesignerSelectionListAdapter.cs
- Listbox.cs
- Funcletizer.cs
- DiagnosticsConfigurationHandler.cs
- TableRowCollection.cs
- ValidationHelpers.cs