Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Activities / System / ServiceModel / Activities / ReceiveMessageContent.cs / 1305376 / ReceiveMessageContent.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Activities { using System.Activities; using System.ComponentModel; using System.Runtime; using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.Windows.Markup; [ContentProperty("Message")] public sealed class ReceiveMessageContent : ReceiveContent { public ReceiveMessageContent() : base() { } public ReceiveMessageContent(OutArgument message) : this() { this.Message = message; } public ReceiveMessageContent(OutArgument message, Type declaredMessageType) : this(message) { this.DeclaredMessageType = declaredMessageType; } // The value that is received as the body of the message. // The type is derived from Message.Expression.ResultType. If the optional // DeclaredMessageType property is also specified, it is validated against // Message.Expression.ResultType. [DefaultValue(null)] public OutArgument Message { get; set; } // Allows the type of the variable specified for Message to be a derived type from the type // on the message contract. This type specifies what the type is one the message contract. // If DeclaredMessageType is not specified, the type from the Message OutArgument is used. // The DeclaredMessageType must either be the same as the type of the OutArgument Message, // or it must be a base type of Message. [DefaultValue(null)] public Type DeclaredMessageType { get; set; } internal Type InternalDeclaredMessageType { get { if (this.DeclaredMessageType == null && this.Message != null) { return this.Message.ArgumentType; } else { return this.DeclaredMessageType; } } } [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeDeclaredMessageType() { // don't serialize null if (this.DeclaredMessageType == null) { return false; } // if the expression type of Message matches the declared message type, no need to serialize duplicative information if (this.Message != null && this.DeclaredMessageType == this.Message.ArgumentType) { return false; } return true; } internal override void CacheMetadata(ActivityMetadata metadata, Activity owner, string operationName) { MessagingActivityHelper.FixMessageArgument(this.Message, ArgumentDirection.Out, metadata); if (this.DeclaredMessageType != null) { if (this.Message == null && this.DeclaredMessageType != TypeHelper.VoidType) { string errorOperationName = ContractValidationHelper.GetErrorMessageOperationName(operationName); metadata.AddValidationError(SR.ValueCannotBeNull(owner.DisplayName, errorOperationName)); } else if (this.Message != null && !this.DeclaredMessageType.IsAssignableFrom(this.Message.ArgumentType)) { string errorOperationName = ContractValidationHelper.GetErrorMessageOperationName(operationName); metadata.AddValidationError(SR.ValueArgumentTypeNotDerivedFromValueType(owner.DisplayName, errorOperationName)); } } } internal override void ConfigureInternalReceive(InternalReceiveMessage internalReceiveMessage, out FromRequest requestFormatter) { if (this.InternalDeclaredMessageType == MessageDescription.TypeOfUntypedMessage) { internalReceiveMessage.Message = new OutArgument(context => ((OutArgument )this.Message).Get(context)); requestFormatter = null; } else { requestFormatter = new FromRequest(); if (this.Message != null) { requestFormatter.Parameters.Add(OutArgument.CreateReference(this.Message, "Message")); } } } internal override void ConfigureInternalReceiveReply(InternalReceiveMessage internalReceiveMessage, out FromReply responseFormatter) { if (this.InternalDeclaredMessageType == MessageDescription.TypeOfUntypedMessage) { // do not use the formatter in this case internalReceiveMessage.Message = new OutArgument (context => ((OutArgument )this.Message).Get(context)); responseFormatter = null; } else { responseFormatter = new FromReply(); // WCF rule dictates that MessageContract must be bound to ReturnValue, not Parameters if (MessageBuilder.IsMessageContract(this.InternalDeclaredMessageType)) { responseFormatter.Result = OutArgument.CreateReference(this.Message, "Message"); } else if (this.Message != null) { responseFormatter.Parameters.Add(OutArgument.CreateReference(this.Message, "Message")); } } } internal override void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction) { ContractInferenceHelper.CheckForDisposableParameters(operation, this.InternalDeclaredMessageType); string overridingAction = null; SerializerOption serializerOption = SerializerOption.DataContractSerializer; Receive receive = owner as Receive; if (receive != null) { overridingAction = receive.Action; serializerOption = receive.SerializerOption; } else { ReceiveReply receiveReply = owner as ReceiveReply; Fx.Assert(receiveReply != null, "The owner of ReceiveMessageContent can only be Receive or ReceiveReply!"); overridingAction = receiveReply.Action; serializerOption = receiveReply.Request.SerializerOption; } if (direction == MessageDirection.Input) { ContractInferenceHelper.AddInputMessage(operation, overridingAction, this.InternalDeclaredMessageType, serializerOption); } else { ContractInferenceHelper.AddOutputMessage(operation, overridingAction, this.InternalDeclaredMessageType, serializerOption); } } } } // 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
- DBDataPermissionAttribute.cs
- SwitchAttribute.cs
- String.cs
- StreamingContext.cs
- ProxyAttribute.cs
- XmlParserContext.cs
- BindingListCollectionView.cs
- CharacterHit.cs
- Dictionary.cs
- ValueUtilsSmi.cs
- ReadOnlyDataSourceView.cs
- DataPagerCommandEventArgs.cs
- FormsAuthentication.cs
- BitmapEffectGroup.cs
- Stack.cs
- ProxyElement.cs
- ClientBuildManagerCallback.cs
- HttpListenerContext.cs
- ResourcePermissionBaseEntry.cs
- InspectionWorker.cs
- DocumentPageHost.cs
- TransformedBitmap.cs
- Literal.cs
- DataGridViewCheckBoxColumn.cs
- DataListItemEventArgs.cs
- versioninfo.cs
- PageSettings.cs
- TraceListener.cs
- UpdateTranslator.cs
- basevalidator.cs
- LinqDataSourceSelectEventArgs.cs
- DPCustomTypeDescriptor.cs
- RIPEMD160Managed.cs
- SQLRoleProvider.cs
- InArgumentConverter.cs
- wgx_render.cs
- _NestedMultipleAsyncResult.cs
- AspNetSynchronizationContext.cs
- UserControl.cs
- TagMapCollection.cs
- DependentList.cs
- XmlSchemaComplexContent.cs
- SafeCryptContextHandle.cs
- RequestValidator.cs
- XsltLibrary.cs
- __FastResourceComparer.cs
- PictureBox.cs
- GeneralTransform3DGroup.cs
- MultiView.cs
- CommonXSendMessage.cs
- DocumentPageViewAutomationPeer.cs
- TemplatedMailWebEventProvider.cs
- LogSwitch.cs
- AutomationTextAttribute.cs
- CapabilitiesRule.cs
- DataGridViewDataErrorEventArgs.cs
- ProfileSection.cs
- AssociationSetEnd.cs
- SecureConversationSecurityTokenParameters.cs
- InfoCardProofToken.cs
- XmlName.cs
- Model3DGroup.cs
- SqlDataSourceConfigureSelectPanel.cs
- ListViewHitTestInfo.cs
- EntityAdapter.cs
- SqlUDTStorage.cs
- OrderPreservingMergeHelper.cs
- ColorContext.cs
- EncodingNLS.cs
- PageAdapter.cs
- ValidationSummary.cs
- ReadWriteSpinLock.cs
- ProviderUtil.cs
- _AutoWebProxyScriptHelper.cs
- DataGridViewRowStateChangedEventArgs.cs
- Cursors.cs
- Int32EqualityComparer.cs
- NotifyInputEventArgs.cs
- DecoderExceptionFallback.cs
- TypeUtil.cs
- Stroke2.cs
- MetaType.cs
- HashSetEqualityComparer.cs
- TextContainerChangedEventArgs.cs
- TrackingMemoryStream.cs
- DataViewSettingCollection.cs
- Stylus.cs
- XmlAttributeCollection.cs
- HwndHostAutomationPeer.cs
- XhtmlConformanceSection.cs
- EastAsianLunisolarCalendar.cs
- SmtpNegotiateAuthenticationModule.cs
- IPipelineRuntime.cs
- CorrelationService.cs
- RestClientProxyHandler.cs
- MultiTrigger.cs
- DeobfuscatingStream.cs
- UpdateExpressionVisitor.cs
- TextServicesCompartmentEventSink.cs
- SqlCacheDependencyDatabaseCollection.cs