Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Activities / System / ServiceModel / Activities / SendParametersContent.cs / 1305376 / SendParametersContent.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.Runtime.Collections; using System.ServiceModel.Description; using System.Windows.Markup; [ContentProperty("Parameters")] public sealed class SendParametersContent : SendContent { string[] argumentNames; Type[] argumentTypes; public SendParametersContent() : base() { this.Parameters = new OrderedDictionary(); } public SendParametersContent(IDictionary parameters) : base() { if (parameters == null) { throw FxTrace.Exception.ArgumentNull("parameters"); } this.Parameters = new OrderedDictionary (parameters); } public IDictionary Parameters { get; private set; } internal string[] ArgumentNames { get { if (this.argumentNames == null) { ShredParameters(); } return this.argumentNames; } } internal Type[] ArgumentTypes { get { if (this.argumentTypes == null) { ShredParameters(); } return this.argumentTypes; } } internal override bool IsFault { get { if (this.ArgumentTypes.Length == 1) { return ContractInferenceHelper.ExceptionType.IsAssignableFrom(this.ArgumentTypes[0]); } else { return false; } } } void ShredParameters() { // Turn Dictionary into ordered Argument arrays int argumentCount = this.Parameters.Count; this.argumentNames = new string[argumentCount]; this.argumentTypes = new Type[argumentCount]; int index = 0; foreach (KeyValuePair pair in this.Parameters) { this.argumentNames[index] = pair.Key; this.argumentTypes[index] = pair.Value.ArgumentType; index++; } } internal override void CacheMetadata(ActivityMetadata metadata, Activity owner, string operationName) { // force a shred for every CacheMetadata call ShredParameters(); int index = 0; foreach (Type argumentType in this.argumentTypes) { if (argumentType == null || argumentType == TypeHelper.VoidType) { metadata.AddValidationError(SR.ArgumentCannotHaveNullOrVoidType(owner.DisplayName, argumentNames[index])); } if (argumentType == MessageDescription.TypeOfUntypedMessage || MessageBuilder.IsMessageContract(argumentType)) { metadata.AddValidationError(SR.SendParametersContentDoesNotSupportMessage(owner.DisplayName, argumentNames[index])); } index++; } if (!metadata.HasViolations) { foreach (KeyValuePair pair in this.Parameters) { RuntimeArgument newRuntimeArgument = new RuntimeArgument(pair.Key, pair.Value.ArgumentType, ArgumentDirection.In); metadata.Bind(pair.Value, newRuntimeArgument); metadata.AddArgument(newRuntimeArgument); } } } internal override void ConfigureInternalSend(InternalSendMessage internalSendMessage, out ToRequest requestFormatter) { //Zero or more arguments requestFormatter = new ToRequest(); foreach (KeyValuePair parameter in this.Parameters) { requestFormatter.Parameters.Add(InArgument.CreateReference(parameter.Value, parameter.Key)); } } internal override void ConfigureInternalSendReply(InternalSendMessage internalSendMessage, out ToReply responseFormatter) { responseFormatter = new ToReply(); foreach (KeyValuePair parameter in this.Parameters) { responseFormatter.Parameters.Add(InArgument.CreateReference(parameter.Value, parameter.Key)); } } internal override void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction) { ContractInferenceHelper.CheckForDisposableParameters(operation, this.ArgumentTypes); string overridingAction = owner is Send ? ((Send)owner).Action : ((SendReply)owner).Action; if (direction == MessageDirection.Input) { ContractInferenceHelper.AddInputMessage(operation, overridingAction, this.ArgumentNames, this.ArgumentTypes); } else { ContractInferenceHelper.AddOutputMessage(operation, overridingAction, this.ArgumentNames, this.ArgumentTypes); } } } } // 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
- InvokeMethodActivity.cs
- InputBinder.cs
- SafePointer.cs
- CachedCompositeFamily.cs
- RepeatBehavior.cs
- PrtCap_Base.cs
- FastEncoderWindow.cs
- DocumentViewerAutomationPeer.cs
- InstanceKeyView.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- AccessViolationException.cs
- SQLBinary.cs
- WindowsRebar.cs
- DataExpression.cs
- Int32AnimationUsingKeyFrames.cs
- DrawingContextWalker.cs
- MaskedTextBoxDesigner.cs
- XmlWriterTraceListener.cs
- XmlSignificantWhitespace.cs
- grammarelement.cs
- PixelFormat.cs
- MetadataException.cs
- RSAPKCS1SignatureFormatter.cs
- ContextBase.cs
- HttpCapabilitiesBase.cs
- XmlDataLoader.cs
- DictionaryItemsCollection.cs
- PropertyHelper.cs
- EntityContainerEntitySet.cs
- MenuAdapter.cs
- SecurityCriticalDataForSet.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- ActivityTypeDesigner.xaml.cs
- ConnectionsZone.cs
- Int16Storage.cs
- HwndProxyElementProvider.cs
- DataGridViewCellMouseEventArgs.cs
- CustomAttributeSerializer.cs
- BasicBrowserDialog.cs
- ReadOnlyKeyedCollection.cs
- XmlBinaryReader.cs
- ListBoxAutomationPeer.cs
- FieldCollectionEditor.cs
- DataGridViewUtilities.cs
- PeerOutputChannel.cs
- XmlTextAttribute.cs
- Effect.cs
- _LocalDataStoreMgr.cs
- BlurBitmapEffect.cs
- ScrollItemProviderWrapper.cs
- Point3DAnimationUsingKeyFrames.cs
- OleDbInfoMessageEvent.cs
- TrackingProfileDeserializationException.cs
- HttpConfigurationContext.cs
- WindowsTokenRoleProvider.cs
- BooleanSwitch.cs
- Signature.cs
- XmlQueryType.cs
- GridViewUpdateEventArgs.cs
- isolationinterop.cs
- CommentEmitter.cs
- AddInController.cs
- ListViewCommandEventArgs.cs
- HwndTarget.cs
- DesignerAdapterUtil.cs
- DecimalKeyFrameCollection.cs
- ProgramPublisher.cs
- EntityDataSourceDesigner.cs
- ObjectComplexPropertyMapping.cs
- LocatorGroup.cs
- AssemblyAttributesGoHere.cs
- CodeTypeDeclarationCollection.cs
- GlyphRun.cs
- CompilationRelaxations.cs
- CharacterShapingProperties.cs
- DesignTimeTemplateParser.cs
- SchemaAttDef.cs
- CurrentChangedEventManager.cs
- XmlArrayItemAttributes.cs
- OracleParameterCollection.cs
- AspNetSynchronizationContext.cs
- TraceContext.cs
- RoleBoolean.cs
- XamlVector3DCollectionSerializer.cs
- UnlockInstanceAsyncResult.cs
- ITreeGenerator.cs
- LiteralControl.cs
- CallbackWrapper.cs
- OracleBinary.cs
- WebControl.cs
- DelayedRegex.cs
- Model3DCollection.cs
- TreeChangeInfo.cs
- BrushConverter.cs
- AssemblyAttributes.cs
- BitmapCodecInfoInternal.cs
- UpdateInfo.cs
- PatternMatcher.cs
- UpdateException.cs
- KeyNotFoundException.cs