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
- XmlSchemaAnyAttribute.cs
- WindowsListViewItemStartMenu.cs
- RichTextBox.cs
- InkSerializer.cs
- HMAC.cs
- RemotingConfigParser.cs
- LogFlushAsyncResult.cs
- SqlDataReader.cs
- SqlUserDefinedAggregateAttribute.cs
- SqlNodeAnnotations.cs
- XmlDictionaryString.cs
- AssertUtility.cs
- IndicShape.cs
- GroupItemAutomationPeer.cs
- ResourceSetExpression.cs
- ClientSettingsStore.cs
- InfoCardTrace.cs
- GlyphTypeface.cs
- ClientCredentials.cs
- SerialStream.cs
- DataFormats.cs
- AppDomainProtocolHandler.cs
- OdbcDataAdapter.cs
- DependencyStoreSurrogate.cs
- XamlBrushSerializer.cs
- RoutedEventHandlerInfo.cs
- SupportingTokenParameters.cs
- UdpSocketReceiveManager.cs
- PrintDialog.cs
- CodeTypeMember.cs
- VisualTarget.cs
- BamlRecords.cs
- SqlCacheDependency.cs
- IsolatedStorageFileStream.cs
- StreamGeometry.cs
- EmptyStringExpandableObjectConverter.cs
- CodeMemberMethod.cs
- DataErrorValidationRule.cs
- WebPartDeleteVerb.cs
- StateManagedCollection.cs
- ProfilePropertySettingsCollection.cs
- DigitShape.cs
- DeferredRunTextReference.cs
- XamlReader.cs
- HGlobalSafeHandle.cs
- Oid.cs
- TextEditorContextMenu.cs
- SchemaNames.cs
- ViewBase.cs
- WebPartTransformerCollection.cs
- GeometryValueSerializer.cs
- ViewEventArgs.cs
- TraceData.cs
- TrackingServices.cs
- SystemTcpConnection.cs
- PhoneCall.cs
- TokenBasedSetEnumerator.cs
- FilterFactory.cs
- JoinGraph.cs
- LookupBindingPropertiesAttribute.cs
- CharacterBufferReference.cs
- NamedPipeHostedTransportConfiguration.cs
- DbConnectionPoolOptions.cs
- EFTableProvider.cs
- EntityDataSourceValidationException.cs
- PopupRoot.cs
- CAGDesigner.cs
- TextDecorationLocationValidation.cs
- DBDataPermission.cs
- MenuStrip.cs
- BinaryMethodMessage.cs
- XmlParserContext.cs
- DrawingServices.cs
- CommandField.cs
- CompilerWrapper.cs
- UnSafeCharBuffer.cs
- TdsEnums.cs
- WSFederationHttpBinding.cs
- ConditionalDesigner.cs
- ConfigurationValue.cs
- ScrollProviderWrapper.cs
- SiteOfOriginContainer.cs
- FileDialogCustomPlace.cs
- TextTreeTextNode.cs
- DbParameterCollection.cs
- RecognitionEventArgs.cs
- FileLogRecordStream.cs
- LockedBorderGlyph.cs
- LinqExpressionNormalizer.cs
- DataGridRowEventArgs.cs
- SafeReversePInvokeHandle.cs
- NameTable.cs
- columnmapkeybuilder.cs
- BindingCompleteEventArgs.cs
- HttpCookie.cs
- QilFactory.cs
- ActivationWorker.cs
- DependencyObjectValidator.cs
- TemplateColumn.cs
- Roles.cs