Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / Configuration / WebRequestModuleElement.cs / 1 / WebRequestModuleElement.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Configuration { using System; using System.Configuration; using System.ComponentModel; using System.Globalization; using System.Reflection; using System.Security.Permissions; public sealed class WebRequestModuleElement : ConfigurationElement { public WebRequestModuleElement() { this.properties.Add(this.prefix); this.properties.Add(this.type); } public WebRequestModuleElement(string prefix, string type) : this() { this.Prefix = prefix; this[this.type] = new TypeAndName(type); } public WebRequestModuleElement(string prefix, Type type) : this() { this.Prefix = prefix; this.Type = type; } protected override ConfigurationPropertyCollection Properties { get { return this.properties; } } [ConfigurationProperty(ConfigurationStrings.Prefix, IsRequired=true, IsKey = true)] public string Prefix { get { return (string)this[this.prefix]; } set { this[this.prefix] = value; } } [ConfigurationProperty(ConfigurationStrings.Type)] [TypeConverter(typeof(TypeTypeConverter))] public Type Type { get { TypeAndName typeName = (TypeAndName)this[this.type]; if (typeName != null) { return typeName.type; } else { return null; } } set { this[this.type] = new TypeAndName(value); } } internal string Key { get { return this.Prefix; } } ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); readonly ConfigurationProperty prefix = new ConfigurationProperty(ConfigurationStrings.Prefix, typeof(string), null, ConfigurationPropertyOptions.IsKey); readonly ConfigurationProperty type = new ConfigurationProperty(ConfigurationStrings.Type, typeof(TypeAndName), null, new TypeTypeConverter(), null, ConfigurationPropertyOptions.None); class TypeAndName { public TypeAndName(string name) { this.type = Type.GetType(name, true, true); this.name = name; } public TypeAndName(Type type) { this.type = type; } public override int GetHashCode() { return type.GetHashCode(); } public override bool Equals(object comparand) { return type.Equals(((TypeAndName) comparand).type); } public readonly Type type; public readonly string name; } class TypeTypeConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { return new TypeAndName((string) value); } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { TypeAndName castedValue = (TypeAndName) value; return castedValue.name == null ? castedValue.type.AssemblyQualifiedName : castedValue.name; } return base.ConvertTo(context, culture, value, destinationType); } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FixedPageAutomationPeer.cs
- CharacterMetricsDictionary.cs
- DataRecord.cs
- RefType.cs
- SqlDataSourceEnumerator.cs
- HttpModuleAction.cs
- RouteParametersHelper.cs
- XPathException.cs
- RayHitTestParameters.cs
- CryptoHandle.cs
- TakeQueryOptionExpression.cs
- DataServiceBuildProvider.cs
- DataPagerField.cs
- EditingCommands.cs
- xmlfixedPageInfo.cs
- CannotUnloadAppDomainException.cs
- ToolTipService.cs
- DeclaredTypeValidator.cs
- ModelItemImpl.cs
- UDPClient.cs
- AccessKeyManager.cs
- StringUtil.cs
- SqlBooleanMismatchVisitor.cs
- ProgressBar.cs
- RepeatBehaviorConverter.cs
- CompilationSection.cs
- XamlReader.cs
- XmlBoundElement.cs
- WinFormsUtils.cs
- NamedElement.cs
- XmlLanguage.cs
- ThrowHelper.cs
- MemberExpression.cs
- PreviewPrintController.cs
- DataGridViewHitTestInfo.cs
- SmiContext.cs
- UmAlQuraCalendar.cs
- SynchronizationScope.cs
- ErrorFormatterPage.cs
- CipherData.cs
- XMLSyntaxException.cs
- XmlCharType.cs
- IpcChannel.cs
- TypeSystem.cs
- OracleDataAdapter.cs
- BasicHttpBindingElement.cs
- UnsafeNativeMethods.cs
- ButtonColumn.cs
- NameTable.cs
- MarkupCompiler.cs
- UndirectedGraph.cs
- printdlgexmarshaler.cs
- CompensationHandlingFilter.cs
- configsystem.cs
- FactoryRecord.cs
- _OSSOCK.cs
- AutoGeneratedFieldProperties.cs
- NativeMethods.cs
- ObjectPersistData.cs
- RegexCompilationInfo.cs
- SponsorHelper.cs
- XslNumber.cs
- EndCreateSecurityTokenRequest.cs
- Membership.cs
- TextMetrics.cs
- ListBindableAttribute.cs
- DuplexChannelBinder.cs
- DataGridItemEventArgs.cs
- DbConnectionPoolCounters.cs
- ECDiffieHellmanPublicKey.cs
- SafeLibraryHandle.cs
- PersonalizableTypeEntry.cs
- SpotLight.cs
- RowTypePropertyElement.cs
- IPAddressCollection.cs
- MatrixStack.cs
- IdentityManager.cs
- LinqDataSourceHelper.cs
- FramingDecoders.cs
- EntityDesignerDataSourceView.cs
- ReachDocumentReferenceCollectionSerializerAsync.cs
- XmlILAnnotation.cs
- XPathEmptyIterator.cs
- KeyedQueue.cs
- DataSet.cs
- _NegoStream.cs
- GetWinFXPath.cs
- IFlowDocumentViewer.cs
- TemplateColumn.cs
- BrowserPolicyValidator.cs
- DeclarativeCatalogPartDesigner.cs
- DrawingImage.cs
- DataGridTextBox.cs
- TdsParserHelperClasses.cs
- AssemblyAttributes.cs
- RandomNumberGenerator.cs
- ToolStripGripRenderEventArgs.cs
- WindowsSlider.cs
- LinkedResourceCollection.cs
- TextBoxBase.cs