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
- MsmqIntegrationMessageProperty.cs
- ZoneLinkButton.cs
- Empty.cs
- XmlSerializerSection.cs
- ConsumerConnectionPointCollection.cs
- PickBranch.cs
- COMException.cs
- DbParameterHelper.cs
- BackgroundFormatInfo.cs
- ConfigurationSchemaErrors.cs
- InternalBufferOverflowException.cs
- SharedPersonalizationStateInfo.cs
- ConstNode.cs
- TransformPatternIdentifiers.cs
- ResXResourceWriter.cs
- Form.cs
- CellConstant.cs
- ConfigurationManagerInternal.cs
- SetStoryboardSpeedRatio.cs
- XmlValidatingReader.cs
- ColorConverter.cs
- UrlSyndicationContent.cs
- EdmSchemaAttribute.cs
- ListViewUpdatedEventArgs.cs
- SqlProfileProvider.cs
- InstancePersistenceCommand.cs
- XmlCollation.cs
- ExtenderHelpers.cs
- EntityDataSourceViewSchema.cs
- Component.cs
- DataGridViewRowConverter.cs
- NonPrimarySelectionGlyph.cs
- ColumnResizeUndoUnit.cs
- filewebresponse.cs
- WebConfigurationFileMap.cs
- StrongBox.cs
- CommandEventArgs.cs
- ItemType.cs
- StorageMappingItemCollection.cs
- DSACryptoServiceProvider.cs
- OleStrCAMarshaler.cs
- ServiceOperationListItemList.cs
- ViewKeyConstraint.cs
- StringComparer.cs
- RemoteWebConfigurationHostStream.cs
- ConfigurationElementCollection.cs
- BooleanExpr.cs
- SmtpClient.cs
- ValidatorCollection.cs
- NavigationProgressEventArgs.cs
- _FtpControlStream.cs
- AuthStoreRoleProvider.cs
- FlagsAttribute.cs
- ArgumentException.cs
- GridViewRow.cs
- QueryIntervalOp.cs
- PopOutPanel.cs
- Rotation3D.cs
- InvalidMessageContractException.cs
- SettingsPropertyIsReadOnlyException.cs
- AmbientValueAttribute.cs
- PreProcessInputEventArgs.cs
- CodeDirectionExpression.cs
- ObjectConverter.cs
- ImageSource.cs
- GridViewColumnCollectionChangedEventArgs.cs
- XhtmlTextWriter.cs
- DetailsViewDeleteEventArgs.cs
- DiscreteKeyFrames.cs
- SimpleFileLog.cs
- SystemThemeKey.cs
- ToolboxSnapDragDropEventArgs.cs
- DodSequenceMerge.cs
- HttpCapabilitiesSectionHandler.cs
- PasswordTextNavigator.cs
- MenuItemBinding.cs
- KeyFrames.cs
- ObjectDataSourceDisposingEventArgs.cs
- PackageDigitalSignatureManager.cs
- Delegate.cs
- DataGridViewComboBoxColumn.cs
- MSG.cs
- DesignSurfaceManager.cs
- oledbmetadatacolumnnames.cs
- ExpressionBuilder.cs
- KnownColorTable.cs
- TranslateTransform.cs
- OutputScope.cs
- ObjectNavigationPropertyMapping.cs
- _ContextAwareResult.cs
- BaseProcessor.cs
- MasterPage.cs
- RemotingService.cs
- MonthChangedEventArgs.cs
- ControlParameter.cs
- SqlUDTStorage.cs
- ToolStripTextBox.cs
- OptimalBreakSession.cs
- ValidationManager.cs
- RtfToken.cs