Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Web / System / Web / Services / Configuration / SoapExtensionTypeElement.cs / 1305376 / SoapExtensionTypeElement.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Web.Services.Configuration { using System; using System.ComponentModel; using System.Configuration; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Security.Permissions; public sealed class SoapExtensionTypeElement : ConfigurationElement { // These three constructors are used by the configuration system. public SoapExtensionTypeElement() : base() { this.properties.Add(this.group); this.properties.Add(this.priority); this.properties.Add(this.type); } public SoapExtensionTypeElement(string type, int priority, PriorityGroup group) : this() { this.Type = Type.GetType(type, true, true); this.Priority = priority; this.Group = group; } public SoapExtensionTypeElement(Type type, int priority, PriorityGroup group) : this(type.AssemblyQualifiedName, priority, group) { } [ConfigurationProperty("group", IsKey = true, DefaultValue = PriorityGroup.Low)] public PriorityGroup Group { get { return (PriorityGroup)base[this.group]; } set { if (Enum.IsDefined(typeof(PriorityGroup), value)) { base[this.group] = value; } else { throw new ArgumentException(Res.GetString(Res.Invalid_priority_group_value), "value"); } } } [ConfigurationProperty("priority", IsKey = true, DefaultValue = 0)] [IntegerValidator(MinValue = 0)] public int Priority { get { return (int)base[this.priority]; } set { base[this.priority] = value; } } [ConfigurationProperty("type", IsKey = true)] [TypeConverter(typeof(TypeTypeConverter))] public Type Type { get { return (Type)base[this.type]; } set { base[this.type] = value; } } protected override ConfigurationPropertyCollection Properties { get { return this.properties; } } ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); readonly ConfigurationProperty group = new ConfigurationProperty("group", typeof(PriorityGroup), PriorityGroup.Low, new EnumConverter(typeof(PriorityGroup)), null, ConfigurationPropertyOptions.IsKey); readonly ConfigurationProperty priority = new ConfigurationProperty("priority", typeof(int), 0, null, new IntegerValidator( 0, int.MaxValue ), ConfigurationPropertyOptions.IsKey); readonly ConfigurationProperty type = new ConfigurationProperty("type", typeof(Type), null, new TypeTypeConverter(), null, ConfigurationPropertyOptions.IsKey); } class TypeTypeConverter : TypeAndNameConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { TypeAndName baseValue = (TypeAndName)base.ConvertFrom(context, culture, value); return baseValue.type; } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { TypeAndName castedValue = new TypeAndName((Type)value); return base.ConvertTo(context, culture, castedValue, destinationType); } return base.ConvertTo(context, culture, value, destinationType); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Web.Services.Configuration { using System; using System.ComponentModel; using System.Configuration; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Security.Permissions; public sealed class SoapExtensionTypeElement : ConfigurationElement { // These three constructors are used by the configuration system. public SoapExtensionTypeElement() : base() { this.properties.Add(this.group); this.properties.Add(this.priority); this.properties.Add(this.type); } public SoapExtensionTypeElement(string type, int priority, PriorityGroup group) : this() { this.Type = Type.GetType(type, true, true); this.Priority = priority; this.Group = group; } public SoapExtensionTypeElement(Type type, int priority, PriorityGroup group) : this(type.AssemblyQualifiedName, priority, group) { } [ConfigurationProperty("group", IsKey = true, DefaultValue = PriorityGroup.Low)] public PriorityGroup Group { get { return (PriorityGroup)base[this.group]; } set { if (Enum.IsDefined(typeof(PriorityGroup), value)) { base[this.group] = value; } else { throw new ArgumentException(Res.GetString(Res.Invalid_priority_group_value), "value"); } } } [ConfigurationProperty("priority", IsKey = true, DefaultValue = 0)] [IntegerValidator(MinValue = 0)] public int Priority { get { return (int)base[this.priority]; } set { base[this.priority] = value; } } [ConfigurationProperty("type", IsKey = true)] [TypeConverter(typeof(TypeTypeConverter))] public Type Type { get { return (Type)base[this.type]; } set { base[this.type] = value; } } protected override ConfigurationPropertyCollection Properties { get { return this.properties; } } ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); readonly ConfigurationProperty group = new ConfigurationProperty("group", typeof(PriorityGroup), PriorityGroup.Low, new EnumConverter(typeof(PriorityGroup)), null, ConfigurationPropertyOptions.IsKey); readonly ConfigurationProperty priority = new ConfigurationProperty("priority", typeof(int), 0, null, new IntegerValidator( 0, int.MaxValue ), ConfigurationPropertyOptions.IsKey); readonly ConfigurationProperty type = new ConfigurationProperty("type", typeof(Type), null, new TypeTypeConverter(), null, ConfigurationPropertyOptions.IsKey); } class TypeTypeConverter : TypeAndNameConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { TypeAndName baseValue = (TypeAndName)base.ConvertFrom(context, culture, value); return baseValue.type; } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { TypeAndName castedValue = new TypeAndName((Type)value); return base.ConvertTo(context, culture, castedValue, destinationType); } return base.ConvertTo(context, culture, value, destinationType); } } } // 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
- Invariant.cs
- StringExpressionSet.cs
- DependencyPropertyValueSerializer.cs
- HttpHandlerActionCollection.cs
- InvokeMethod.cs
- SqlExpressionNullability.cs
- MobileControlPersister.cs
- CounterSampleCalculator.cs
- SendMailErrorEventArgs.cs
- FileDialog_Vista_Interop.cs
- PrintPageEvent.cs
- Nodes.cs
- NativeMethods.cs
- APCustomTypeDescriptor.cs
- Win32.cs
- GestureRecognizer.cs
- SaveCardRequest.cs
- InfiniteIntConverter.cs
- ToolStripMenuItem.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- DebugInfoExpression.cs
- EraserBehavior.cs
- DataView.cs
- AnnotationHelper.cs
- OleDbConnectionInternal.cs
- CellTreeNodeVisitors.cs
- ScriptComponentDescriptor.cs
- DeclaredTypeValidator.cs
- ReadOnlyNameValueCollection.cs
- SaveFileDialog.cs
- VectorCollection.cs
- ZipFileInfo.cs
- unsafenativemethodstextservices.cs
- storagemappingitemcollection.viewdictionary.cs
- AdornerHitTestResult.cs
- QilTernary.cs
- CroppedBitmap.cs
- LayoutTable.cs
- ExpressionBinding.cs
- JsonReaderDelegator.cs
- BCLDebug.cs
- Sequence.cs
- SingleSelectRootGridEntry.cs
- ErasingStroke.cs
- RectKeyFrameCollection.cs
- SingleAnimation.cs
- JsonSerializer.cs
- FormatException.cs
- PropertyInformation.cs
- EpmCustomContentWriterNodeData.cs
- OleDbSchemaGuid.cs
- StructuredTypeEmitter.cs
- TableCell.cs
- EntityDescriptor.cs
- IPEndPointCollection.cs
- ReachPrintTicketSerializer.cs
- webeventbuffer.cs
- XmlSchemaSimpleContentExtension.cs
- LOSFormatter.cs
- DesignerVerb.cs
- XmlIterators.cs
- TimeZoneNotFoundException.cs
- ConfigurationConverterBase.cs
- WorkItem.cs
- SymbolType.cs
- MemoryStream.cs
- DataGridViewTextBoxCell.cs
- AxisAngleRotation3D.cs
- DataGridViewTextBoxColumn.cs
- DesignerWebPartChrome.cs
- FileDialogCustomPlace.cs
- ChannelPool.cs
- NamespaceExpr.cs
- WindowsListViewSubItem.cs
- BinaryObjectReader.cs
- LocalBuilder.cs
- NamespaceExpr.cs
- EventsTab.cs
- Set.cs
- DocumentXmlWriter.cs
- SimplePropertyEntry.cs
- Nodes.cs
- GridViewUpdatedEventArgs.cs
- WinFormsUtils.cs
- DesignerOptionService.cs
- ICspAsymmetricAlgorithm.cs
- Math.cs
- CodeEventReferenceExpression.cs
- File.cs
- NetworkAddressChange.cs
- TraceContextRecord.cs
- DataConnectionHelper.cs
- XamlFigureLengthSerializer.cs
- ErrorTableItemStyle.cs
- MenuItem.cs
- PrimitiveType.cs
- RoleGroupCollection.cs
- SettingsPropertyNotFoundException.cs
- RequestCacheManager.cs
- DataGridViewComponentPropertyGridSite.cs