Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Activities / System / ServiceModel / Activities / ReceiveParametersContent.cs / 1305376 / ReceiveParametersContent.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 ReceiveParametersContent : ReceiveContent
{
string[] argumentNames;
Type[] argumentTypes;
public ReceiveParametersContent()
: base()
{
this.Parameters = new OrderedDictionary();
}
public ReceiveParametersContent(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;
}
}
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.ReceiveParametersContentDoesNotSupportMessage(owner.DisplayName, argumentNames[index]));
}
index++;
}
if (!metadata.HasViolations)
{
foreach (KeyValuePair pair in this.Parameters)
{
RuntimeArgument newRuntimeArgument = new RuntimeArgument(pair.Key, pair.Value.ArgumentType, ArgumentDirection.Out);
metadata.Bind(pair.Value, newRuntimeArgument);
metadata.AddArgument(newRuntimeArgument);
}
}
}
internal override void ConfigureInternalReceive(InternalReceiveMessage internalReceiveMessage, out FromRequest requestFormatter)
{
requestFormatter = new FromRequest();
foreach (KeyValuePair parameter in this.Parameters)
{
requestFormatter.Parameters.Add(OutArgument.CreateReference(parameter.Value, parameter.Key));
}
}
internal override void ConfigureInternalReceiveReply(InternalReceiveMessage internalReceiveMessage, out FromReply responseFormatter)
{
responseFormatter = new FromReply();
foreach (KeyValuePair parameter in this.Parameters)
{
responseFormatter.Parameters.Add(OutArgument.CreateReference(parameter.Value, parameter.Key));
}
}
internal override void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction)
{
ContractInferenceHelper.CheckForDisposableParameters(operation, this.argumentTypes);
string overridingAction = owner is Receive ? ((Receive)owner).Action : ((ReceiveReply)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
- XmlWriterSettings.cs
- RemoteArgument.cs
- StaticTextPointer.cs
- HttpPostedFile.cs
- WindowVisualStateTracker.cs
- OperatingSystem.cs
- BuildResult.cs
- ScrollEvent.cs
- AuthenticationService.cs
- TypeAccessException.cs
- ConfigurationPermission.cs
- TableItemPatternIdentifiers.cs
- BCryptNative.cs
- DataGridViewCellCollection.cs
- InvokeFunc.cs
- MsmqDiagnostics.cs
- Completion.cs
- XamlPoint3DCollectionSerializer.cs
- RoleManagerModule.cs
- XmlValidatingReaderImpl.cs
- ContentElement.cs
- CodeExporter.cs
- PassportAuthenticationModule.cs
- PathSegmentCollection.cs
- BlobPersonalizationState.cs
- MemoryPressure.cs
- ClientConfigurationSystem.cs
- XPathSingletonIterator.cs
- OleDbStruct.cs
- _SingleItemRequestCache.cs
- TextUtf8RawTextWriter.cs
- AnimatedTypeHelpers.cs
- HttpModuleActionCollection.cs
- AutomationProperties.cs
- DelegateBodyWriter.cs
- SqlConnectionStringBuilder.cs
- DelayedRegex.cs
- DataControlPagerLinkButton.cs
- DataGridTable.cs
- NativeMethods.cs
- XPathNavigatorKeyComparer.cs
- PixelFormatConverter.cs
- Int16AnimationUsingKeyFrames.cs
- WindowsSecurityTokenAuthenticator.cs
- PartitionResolver.cs
- WorkflowDesigner.cs
- ApplicationTrust.cs
- IOException.cs
- ArrayElementGridEntry.cs
- XPathSingletonIterator.cs
- ConstrainedDataObject.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- XmlEnumAttribute.cs
- XsdDataContractImporter.cs
- OverlappedAsyncResult.cs
- BaseInfoTable.cs
- ClientScriptManagerWrapper.cs
- RequiredFieldValidator.cs
- HtmlInputSubmit.cs
- CfgParser.cs
- ConstraintStruct.cs
- KeyPressEvent.cs
- LayoutUtils.cs
- SafeNativeMethods.cs
- NumericExpr.cs
- OdbcException.cs
- CategoryNameCollection.cs
- HttpAsyncResult.cs
- DataGridViewCellStyleEditor.cs
- ButtonStandardAdapter.cs
- BulletedListEventArgs.cs
- EntitySetBase.cs
- DbMetaDataCollectionNames.cs
- ObjectViewFactory.cs
- listitem.cs
- HttpHandlersSection.cs
- TableDetailsCollection.cs
- WebPartConnectionsCloseVerb.cs
- CannotUnloadAppDomainException.cs
- ThemeableAttribute.cs
- XmlException.cs
- _Rfc2616CacheValidators.cs
- BrowserCapabilitiesFactory.cs
- XmlValidatingReader.cs
- DataGridRowHeaderAutomationPeer.cs
- FormatterServices.cs
- Span.cs
- SiteMembershipCondition.cs
- TogglePatternIdentifiers.cs
- Debug.cs
- Soap.cs
- MessageBox.cs
- FormatVersion.cs
- DictionaryChange.cs
- WebBaseEventKeyComparer.cs
- CounterCreationData.cs
- CompilationSection.cs
- WebBrowserContainer.cs
- CodeGeneratorAttribute.cs
- FixedSOMFixedBlock.cs