Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Activities / System / ServiceModel / Activities / FromReply.cs / 1305376 / FromReply.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.ServiceModel.Activities { using System.Activities; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime; using System.ServiceModel.Channels; using System.ServiceModel.Dispatcher; using SR2 = System.ServiceModel.Activities.SR; class FromReply : CodeActivity { Collectionparameters; public InArgument Message { get; set; } public IClientMessageFormatter Formatter { get; set; } public IClientFaultFormatter FaultFormatter { get; set; } public OutArgument Result { get; set; } public Collection Parameters { get { if (this.parameters == null) { this.parameters = new Collection (); } return this.parameters; } } protected override void CacheMetadata(CodeActivityMetadata metadata) { RuntimeArgument messageArgument = new RuntimeArgument(Constants.Message, Constants.MessageType, ArgumentDirection.In, true); metadata.Bind(this.Message, messageArgument); metadata.AddArgument(messageArgument); if (this.Result != null) { RuntimeArgument resultArgument = new RuntimeArgument(Constants.Result, this.Result.ArgumentType, ArgumentDirection.Out); metadata.Bind(this.Result, resultArgument); metadata.AddArgument(resultArgument); } if (this.parameters != null) { int count = 0; foreach (OutArgument parameter in this.parameters) { RuntimeArgument parameterArgument = new RuntimeArgument(Constants.Message + count++, parameter.ArgumentType, ArgumentDirection.Out); metadata.Bind(parameter, parameterArgument); metadata.AddArgument(parameterArgument); } } } protected override void Execute(CodeActivityContext context) { Message inMessage = this.Message.Get(context); if (inMessage == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.NullReplyMessageContractMismatch)); } if (inMessage.IsFault) { FaultConverter faultConverter = FaultConverter.GetDefaultFaultConverter(inMessage.Version); Exception exception = DeserializeFault(inMessage, faultConverter); // We simply throw the exception throw FxTrace.Exception.AsError(exception); } else { object[] outObjects; if (this.parameters != null) { outObjects = new object[this.parameters.Count]; } else { outObjects = Constants.EmptyArray; } object returnValue = this.Formatter.DeserializeReply(inMessage, outObjects); if (this.Result != null) { this.Result.Set(context, returnValue); } if (parameters != null) { for (int i = 0; i < this.parameters.Count; i++) { OutArgument outArgument = this.parameters[i]; Fx.Assert(outArgument != null, "Parameter cannot be null"); object obj = outObjects[i]; if (obj == null) { obj = ProxyOperationRuntime.GetDefaultParameterValue(outArgument.ArgumentType); } outArgument.Set(context, obj); } } } } Exception DeserializeFault(Message inMessage, FaultConverter faultConverter) { // Reproduce logic in ClientOperationFormatterHelper MessageFault messageFault = MessageFault.CreateFault(inMessage, TransportDefaults.MaxFaultSize); string action = inMessage.Headers.Action; if (action == inMessage.Version.Addressing.DefaultFaultAction) { action = null; } Exception exception = null; if (faultConverter != null) { faultConverter.TryCreateException(inMessage, messageFault, out exception); } if (exception == null) { exception = this.FaultFormatter.Deserialize(messageFault, action); } if (inMessage.State != MessageState.Created) { inMessage.Close(); } return exception; } } } // 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
- PrintDialogException.cs
- _UriTypeConverter.cs
- StateChangeEvent.cs
- DataGridView.cs
- SchemaImporterExtensionElement.cs
- XhtmlBasicListAdapter.cs
- EdgeModeValidation.cs
- SessionEndingEventArgs.cs
- VBCodeProvider.cs
- LongAverageAggregationOperator.cs
- CultureInfo.cs
- AssociatedControlConverter.cs
- EventProviderWriter.cs
- DescendentsWalker.cs
- Rfc2898DeriveBytes.cs
- UnmanagedMemoryStream.cs
- XamlGridLengthSerializer.cs
- HtmlTableRowCollection.cs
- Privilege.cs
- BasicCellRelation.cs
- CollectionBuilder.cs
- TemplateControl.cs
- Identifier.cs
- Compiler.cs
- RegexWorker.cs
- Directory.cs
- SuppressIldasmAttribute.cs
- DbProviderFactory.cs
- AssociationTypeEmitter.cs
- EmptyWorkItem.cs
- XamlPathDataSerializer.cs
- IdleTimeoutMonitor.cs
- SystemInfo.cs
- DetailsViewPagerRow.cs
- FormsAuthenticationTicket.cs
- ConditionCollection.cs
- RepeaterCommandEventArgs.cs
- SizeChangedEventArgs.cs
- Transform3DCollection.cs
- String.cs
- StorageBasedPackageProperties.cs
- URLString.cs
- SHA1CryptoServiceProvider.cs
- TimelineClockCollection.cs
- TemplatedWizardStep.cs
- ColorBuilder.cs
- CorruptingExceptionCommon.cs
- InheritanceService.cs
- BinaryFormatterWriter.cs
- EntitySetBaseCollection.cs
- dbenumerator.cs
- OSFeature.cs
- WebServiceEndpoint.cs
- ExpanderAutomationPeer.cs
- RecommendedAsConfigurableAttribute.cs
- QueryAccessibilityHelpEvent.cs
- DefinitionBase.cs
- DbDataAdapter.cs
- MasterPageCodeDomTreeGenerator.cs
- NullExtension.cs
- CompositeFontInfo.cs
- ScrollBarRenderer.cs
- RSAPKCS1KeyExchangeFormatter.cs
- BCLDebug.cs
- MetaType.cs
- QilLiteral.cs
- BaseDataList.cs
- CryptographicAttribute.cs
- Brushes.cs
- BinaryMethodMessage.cs
- PrincipalPermission.cs
- ExcCanonicalXml.cs
- WebPartMovingEventArgs.cs
- PrintControllerWithStatusDialog.cs
- _ChunkParse.cs
- AdPostCacheSubstitution.cs
- TreeNodeClickEventArgs.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- TypeDescriptor.cs
- SafeThreadHandle.cs
- HttpRequest.cs
- CultureInfoConverter.cs
- WebBrowsableAttribute.cs
- SamlAuthenticationClaimResource.cs
- UTF32Encoding.cs
- DateTimeAutomationPeer.cs
- SystemBrushes.cs
- XmlSchemaNotation.cs
- TextBoxBase.cs
- KnownBoxes.cs
- SRGSCompiler.cs
- FilePrompt.cs
- InvalidOperationException.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- XslTransformFileEditor.cs
- CalendarBlackoutDatesCollection.cs
- FixedDocumentSequencePaginator.cs
- Maps.cs
- ColorConverter.cs
- AsyncPostBackTrigger.cs