Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Description / DataContractSerializerOperationBehavior.cs / 2 / DataContractSerializerOperationBehavior.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Description { using System; using System.ServiceModel.Channels; using System.ServiceModel.Dispatcher; using System.IO; using System.ServiceModel; using System.Runtime.Serialization; using System.Collections.Generic; using System.Xml; public class DataContractSerializerOperationBehavior : IOperationBehavior, IWsdlExportExtension { readonly bool builtInOperationBehavior; OperationDescription operation; DataContractFormatAttribute dataContractFormatAttribute; internal bool ignoreExtensionDataObject = DataContractSerializerDefaults.IgnoreExtensionDataObject; bool ignoreExtensionDataObjectSetExplicit; internal int maxItemsInObjectGraph = DataContractSerializerDefaults.MaxItemsInObjectGraph; bool maxItemsInObjectGraphSetExplicit; IDataContractSurrogate dataContractSurrogate; public DataContractFormatAttribute DataContractFormatAttribute { get { return dataContractFormatAttribute; } } public DataContractSerializerOperationBehavior(OperationDescription operation) : this(operation, null) { } public DataContractSerializerOperationBehavior(OperationDescription operation, DataContractFormatAttribute dataContractFormatAttribute) { this.dataContractFormatAttribute = dataContractFormatAttribute ?? new DataContractFormatAttribute(); this.operation = operation; } internal DataContractSerializerOperationBehavior(OperationDescription operation, DataContractFormatAttribute dataContractFormatAttribute, bool builtInOperationBehavior) : this(operation, dataContractFormatAttribute) { this.builtInOperationBehavior = builtInOperationBehavior; } internal bool IsBuiltInOperationBehavior { get { return this.builtInOperationBehavior; } } public int MaxItemsInObjectGraph { get { return maxItemsInObjectGraph; } set { maxItemsInObjectGraph = value; maxItemsInObjectGraphSetExplicit = true; } } internal bool MaxItemsInObjectGraphSetExplicit { get { return maxItemsInObjectGraphSetExplicit; } set { maxItemsInObjectGraphSetExplicit = value; } } public bool IgnoreExtensionDataObject { get { return ignoreExtensionDataObject; } set { ignoreExtensionDataObject = value; ignoreExtensionDataObjectSetExplicit = true; } } internal bool IgnoreExtensionDataObjectSetExplicit { get { return ignoreExtensionDataObjectSetExplicit; } set { ignoreExtensionDataObjectSetExplicit = value; } } public IDataContractSurrogate DataContractSurrogate { get { return dataContractSurrogate; } set { dataContractSurrogate = value; } } public virtual XmlObjectSerializer CreateSerializer(Type type, string name, string ns, IListknownTypes) { return new DataContractSerializer(type, name, ns, knownTypes, MaxItemsInObjectGraph, IgnoreExtensionDataObject, false /*preserveObjectReferences*/, DataContractSurrogate); } public virtual XmlObjectSerializer CreateSerializer(Type type, XmlDictionaryString name, XmlDictionaryString ns, IList knownTypes) { return new DataContractSerializer(type, name, ns, knownTypes, MaxItemsInObjectGraph, IgnoreExtensionDataObject, false /*preserveObjectReferences*/, DataContractSurrogate); } object GetFormatter(OperationDescription operation, out bool formatRequest, out bool formatReply, bool isProxy) { MessageDescription request = operation.Messages[0]; MessageDescription response = null; if (operation.Messages.Count == 2) response = operation.Messages[1]; formatRequest = (request != null) && !request.IsUntypedMessage; formatReply = (response != null) && !response.IsUntypedMessage; if (formatRequest || formatReply) { if (PrimitiveOperationFormatter.IsContractSupported(operation)) return new PrimitiveOperationFormatter(operation, dataContractFormatAttribute.Style == OperationFormatStyle.Rpc); else return new DataContractSerializerOperationFormatter(operation, dataContractFormatAttribute, this); } return null; } void IOperationBehavior.Validate(OperationDescription description) { } void IOperationBehavior.AddBindingParameters(OperationDescription description, BindingParameterCollection parameters) { } void IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch) { if (description == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description"); if (dispatch == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dispatch"); if (dispatch.Formatter != null) return; bool formatRequest; bool formatReply; dispatch.Formatter = (IDispatchMessageFormatter)GetFormatter(description, out formatRequest, out formatReply, false); dispatch.DeserializeRequest = formatRequest; dispatch.SerializeReply = formatReply; } void IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy) { if (description == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description"); if (proxy == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("proxy"); if (proxy.Formatter != null) return; bool formatRequest; bool formatReply; proxy.Formatter = (IClientMessageFormatter)GetFormatter(description, out formatRequest, out formatReply, true); proxy.SerializeRequest = formatRequest; proxy.DeserializeReply = formatReply; } void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext) { if (exporter == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter"); if (endpointContext == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext"); MessageContractExporter.ExportMessageBinding(exporter, endpointContext, typeof(DataContractSerializerMessageContractExporter), this.operation); } void IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext contractContext) { if (exporter == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter"); if (contractContext == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractContext"); new DataContractSerializerMessageContractExporter(exporter, contractContext, this.operation, this).ExportMessageContract(); } } } // 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
- XmlSubtreeReader.cs
- SafeProcessHandle.cs
- PathGeometry.cs
- UiaCoreProviderApi.cs
- followingquery.cs
- MSG.cs
- ThreadInterruptedException.cs
- CmsInterop.cs
- CalloutQueueItem.cs
- PathGradientBrush.cs
- SyndicationPerson.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- SafeNativeMethods.cs
- LookupNode.cs
- ProfileBuildProvider.cs
- TextRenderingModeValidation.cs
- XmlMessageFormatter.cs
- GeneratedContractType.cs
- WebPageTraceListener.cs
- MasterPageCodeDomTreeGenerator.cs
- ListViewDeleteEventArgs.cs
- IpcManager.cs
- TemplatedWizardStep.cs
- SystemResources.cs
- Base64Decoder.cs
- ConfigurationSectionGroup.cs
- BatchParser.cs
- WriteFileContext.cs
- DeflateStream.cs
- PersistenceException.cs
- LinearQuaternionKeyFrame.cs
- IpcPort.cs
- WSSecurityPolicy11.cs
- UIElementHelper.cs
- MenuEventArgs.cs
- ServiceDescriptionImporter.cs
- BamlLocalizationDictionary.cs
- TableParagraph.cs
- CopyOfAction.cs
- NullableIntAverageAggregationOperator.cs
- ButtonFieldBase.cs
- Fonts.cs
- ReadContentAsBinaryHelper.cs
- NetDispatcherFaultException.cs
- TdsEnums.cs
- ToolboxItemFilterAttribute.cs
- ValidationRuleCollection.cs
- ApplicationActivator.cs
- NoResizeHandleGlyph.cs
- RemotingAttributes.cs
- ReadOnlyMetadataCollection.cs
- RequestCacheValidator.cs
- BitmapInitialize.cs
- XhtmlBasicPhoneCallAdapter.cs
- SpanIndex.cs
- MultiSelector.cs
- CreateUserErrorEventArgs.cs
- UpdateCommandGenerator.cs
- DbProviderSpecificTypePropertyAttribute.cs
- BackgroundFormatInfo.cs
- XPathNodeHelper.cs
- SchemaAttDef.cs
- WorkflowRuntimeEndpoint.cs
- Int16Storage.cs
- DispatcherHooks.cs
- SemanticResultValue.cs
- ChannelReliableSession.cs
- _UriSyntax.cs
- DecoderExceptionFallback.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- CharConverter.cs
- WebControl.cs
- BoundField.cs
- PreservationFileWriter.cs
- TranslateTransform.cs
- ColumnReorderedEventArgs.cs
- FieldMetadata.cs
- regiisutil.cs
- OdbcEnvironment.cs
- ImageAttributes.cs
- ZipIOModeEnforcingStream.cs
- WebConfigurationFileMap.cs
- AnimationStorage.cs
- Trigger.cs
- XsdSchemaFileEditor.cs
- RegexWriter.cs
- SqlTypesSchemaImporter.cs
- HttpException.cs
- OciEnlistContext.cs
- TextServicesLoader.cs
- TreeBuilderXamlTranslator.cs
- DBDataPermissionAttribute.cs
- BlurEffect.cs
- InkCanvas.cs
- PolyLineSegmentFigureLogic.cs
- HttpsTransportBindingElement.cs
- PageHandlerFactory.cs
- SynchronizationLockException.cs
- GridLengthConverter.cs
- ClockController.cs