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
- DataGridViewTopLeftHeaderCell.cs
- CapiNative.cs
- ToolStripDropTargetManager.cs
- WebPartMovingEventArgs.cs
- MessageQueuePermissionEntryCollection.cs
- WebPartManagerInternals.cs
- RayHitTestParameters.cs
- ActiveDocumentEvent.cs
- HtmlLinkAdapter.cs
- PartBasedPackageProperties.cs
- MulticastNotSupportedException.cs
- BamlResourceSerializer.cs
- TextTrailingCharacterEllipsis.cs
- ValidateNames.cs
- Lease.cs
- DbInsertCommandTree.cs
- DeferredReference.cs
- _HeaderInfoTable.cs
- RawStylusInput.cs
- ChineseLunisolarCalendar.cs
- TemplateKeyConverter.cs
- GridItemPatternIdentifiers.cs
- WebAdminConfigurationHelper.cs
- ErrorEventArgs.cs
- HtmlMeta.cs
- XmlRawWriterWrapper.cs
- Typography.cs
- ServiceContractListItemList.cs
- ExportOptions.cs
- XmlObjectSerializerWriteContextComplex.cs
- ReturnEventArgs.cs
- ArcSegment.cs
- Section.cs
- TreePrinter.cs
- DockPatternIdentifiers.cs
- CfgSemanticTag.cs
- DataGridTextBoxColumn.cs
- TextRangeSerialization.cs
- DataServiceHostFactory.cs
- DataGridAddNewRow.cs
- InvalidOleVariantTypeException.cs
- DependencyPropertyConverter.cs
- VisualStyleInformation.cs
- Bezier.cs
- MemberAccessException.cs
- FormatException.cs
- GenericPrincipal.cs
- InputElement.cs
- sitestring.cs
- ServiceModelReg.cs
- CustomSignedXml.cs
- EnumType.cs
- Matrix3D.cs
- PackageRelationship.cs
- CodeBinaryOperatorExpression.cs
- NetworkInformationPermission.cs
- PreProcessor.cs
- InProcStateClientManager.cs
- SmtpLoginAuthenticationModule.cs
- Permission.cs
- TextTreeRootNode.cs
- CacheForPrimitiveTypes.cs
- BinaryObjectWriter.cs
- EdmScalarPropertyAttribute.cs
- SettingsProperty.cs
- HostedBindingBehavior.cs
- StaticFileHandler.cs
- Color.cs
- SqlGenerator.cs
- CompoundFileStreamReference.cs
- AnnotationHelper.cs
- ListViewGroupConverter.cs
- WorkflowOperationBehavior.cs
- StrokeDescriptor.cs
- COM2ExtendedUITypeEditor.cs
- NetCodeGroup.cs
- XamlVector3DCollectionSerializer.cs
- TablePatternIdentifiers.cs
- GeneralTransformGroup.cs
- BuildManager.cs
- Baml2006ReaderFrame.cs
- DrawingBrush.cs
- NullableFloatAverageAggregationOperator.cs
- FixedHighlight.cs
- FirstMatchCodeGroup.cs
- CommandSet.cs
- HwndSourceKeyboardInputSite.cs
- ProgressBarAutomationPeer.cs
- CachedPathData.cs
- ThreadStateException.cs
- Container.cs
- ScriptingSectionGroup.cs
- ScalarType.cs
- QuaternionAnimation.cs
- GridViewRowEventArgs.cs
- ObjectListDesigner.cs
- ProtectedConfiguration.cs
- EdgeProfileValidation.cs
- WindowsEditBoxRange.cs
- MarkupObject.cs