Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Configuration / MessageVersionConverter.cs / 1 / MessageVersionConverter.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Configuration { using System; using System.ServiceModel.Channels; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.ServiceModel; using System.Globalization; class MessageVersionConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (typeof(string) == sourceType) { return true; } return base.CanConvertFrom(context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (typeof(InstanceDescriptor) == destinationType) { return true; } return base.CanConvertTo(context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value is string) { string messageVersion = (string)value; MessageVersion retval = null; switch (messageVersion) { case ConfigurationStrings.Soap11WSAddressing10: retval = MessageVersion.Soap11WSAddressing10; break; case ConfigurationStrings.Soap12WSAddressing10: retval = MessageVersion.Soap12WSAddressing10; break; case ConfigurationStrings.Soap11WSAddressingAugust2004: retval = MessageVersion.Soap11WSAddressingAugust2004; break; case ConfigurationStrings.Soap12WSAddressingAugust2004: retval = MessageVersion.Soap12WSAddressingAugust2004; break; case ConfigurationStrings.Soap11: retval = MessageVersion.Soap11; break; case ConfigurationStrings.Soap12: retval = MessageVersion.Soap12; break; case ConfigurationStrings.None: retval = MessageVersion.None; break; case ConfigurationStrings.Default: retval = MessageVersion.Default; break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", SR.GetString(SR.ConfigInvalidClassFactoryValue, messageVersion, typeof(MessageVersion).FullName))); } return retval; } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (typeof(string) == destinationType && value is MessageVersion) { string retval = null; MessageVersion messageVersion = (MessageVersion)value; if (messageVersion == MessageVersion.Default) { retval = ConfigurationStrings.Default; } else if (messageVersion == MessageVersion.Soap11WSAddressing10) { retval = ConfigurationStrings.Soap11WSAddressing10; } else if (messageVersion == MessageVersion.Soap12WSAddressing10) { retval = ConfigurationStrings.Soap12WSAddressing10; } else if (messageVersion == MessageVersion.Soap11WSAddressingAugust2004) { retval = ConfigurationStrings.Soap11WSAddressingAugust2004; } else if (messageVersion == MessageVersion.Soap12WSAddressingAugust2004) { retval = ConfigurationStrings.Soap12WSAddressingAugust2004; } else if (messageVersion == MessageVersion.Soap11) { retval = ConfigurationStrings.Soap11; } else if (messageVersion == MessageVersion.Soap12) { retval = ConfigurationStrings.Soap12; } else if (messageVersion == MessageVersion.None) { retval = ConfigurationStrings.None; } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", SR.GetString(SR.ConfigInvalidClassInstanceValue, typeof(MessageVersion).FullName))); } return retval; } 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DomainConstraint.cs
- ExpandSegmentCollection.cs
- XmlByteStreamWriter.cs
- DataSourceCacheDurationConverter.cs
- XmlConvert.cs
- PDBReader.cs
- NTAccount.cs
- ClientBuildManager.cs
- FacetChecker.cs
- PublisherIdentityPermission.cs
- SqlRowUpdatingEvent.cs
- DoubleCollectionValueSerializer.cs
- WinFormsUtils.cs
- BindingWorker.cs
- DiscoveryDocumentReference.cs
- ToolboxItemAttribute.cs
- TouchesCapturedWithinProperty.cs
- ConnectivityStatus.cs
- PerspectiveCamera.cs
- ObjectNavigationPropertyMapping.cs
- securitycriticaldataformultiplegetandset.cs
- ExternalDataExchangeService.cs
- PageWrapper.cs
- NetworkAddressChange.cs
- ClientReliableChannelBinder.cs
- SchemaHelper.cs
- PermissionRequestEvidence.cs
- AssemblyCollection.cs
- Condition.cs
- CodeTypeReferenceCollection.cs
- SqlDataSourceFilteringEventArgs.cs
- WindowsClientElement.cs
- ReferenceEqualityComparer.cs
- UnsafeMethods.cs
- SafeBitVector32.cs
- XmlSerializationReader.cs
- ManifestBasedResourceGroveler.cs
- ExpandCollapseProviderWrapper.cs
- _NegoStream.cs
- EventSinkActivity.cs
- RotationValidation.cs
- ProcessHostMapPath.cs
- SqlDependency.cs
- X509Utils.cs
- PreparingEnlistment.cs
- CodeAttributeDeclaration.cs
- State.cs
- DBSchemaTable.cs
- SqlFileStream.cs
- DeviceOverridableAttribute.cs
- EventSchemaTraceListener.cs
- FixedPosition.cs
- WorkflowPersistenceContext.cs
- Hashtable.cs
- TCPClient.cs
- UrlAuthFailedErrorFormatter.cs
- ControlUtil.cs
- BidPrivateBase.cs
- MetaTable.cs
- ButtonChrome.cs
- BrowserDefinitionCollection.cs
- FontFamilyIdentifier.cs
- MachineKeySection.cs
- Fonts.cs
- _ListenerRequestStream.cs
- AddInPipelineAttributes.cs
- DynamicQueryableWrapper.cs
- XmlSchemaAppInfo.cs
- SignedXml.cs
- BuilderInfo.cs
- OracleConnectionStringBuilder.cs
- StorageBasedPackageProperties.cs
- BitmapFrameEncode.cs
- XmlWriterTraceListener.cs
- Point3DCollectionConverter.cs
- StringReader.cs
- ScriptingSectionGroup.cs
- FixedDSBuilder.cs
- AppDomainAttributes.cs
- PolicyLevel.cs
- NetMsmqSecurityElement.cs
- StylusPointProperty.cs
- LocatorPartList.cs
- TypeElement.cs
- HtmlInputRadioButton.cs
- ChannelServices.cs
- VariableQuery.cs
- DeclarativeCatalogPartDesigner.cs
- SByteConverter.cs
- ChannelListenerBase.cs
- SiteMapPath.cs
- ValidateNames.cs
- ApplicationInfo.cs
- ConstraintCollection.cs
- ObjectSecurity.cs
- WSMessageEncoding.cs
- JsonGlobals.cs
- LocatorManager.cs
- SimpleTextLine.cs
- ConnectionInterfaceCollection.cs