Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / Executors / InboundActivityHelper.cs / 1305376 / InboundActivityHelper.cs
#region Using directives using System; using System.Diagnostics; using System.Collections.Generic; using System.Text; using System.Reflection; using System.Runtime.Remoting; using System.Runtime.Remoting.Messaging; using System.Workflow.Runtime.Hosting; using System.Workflow.ComponentModel; using System.Workflow.Runtime; #endregion namespace System.Workflow.Activities { internal static class InboundActivityHelper { internal static ActivityExecutionStatus ExecuteForActivity(HandleExternalEventActivity activity, ActivityExecutionContext context, Type interfaceType, string operation, out object[] args) { WorkflowQueuingService queueSvcs = (WorkflowQueuingService)context.GetService(typeof(WorkflowQueuingService)); args = null; IComparable queueName = CorrelationService.ResolveQueueName(activity, interfaceType, operation); if (queueName != null) { WorkflowQueue queue; object message = DequeueMessage(queueName, queueSvcs,activity, out queue); CorrelationService.UninitializeFollowers(interfaceType, operation, queue); if (message != null) { args = ProcessEvent(activity, context, message, interfaceType, operation); return ActivityExecutionStatus.Closed; } } return ActivityExecutionStatus.Executing; } internal static object DequeueMessage(IComparable queueId, WorkflowQueuingService queueSvcs, Activity activity, out WorkflowQueue queue) { object message = null; queue = queueSvcs.GetWorkflowQueue(queueId); if (queue.Count != 0) { message = queue.Dequeue(); if (message == null) throw new ArgumentException(SR.GetString(SR.Error_InvalidEventMessage, activity.QualifiedName)); } return message; } private static object[] ProcessEvent(HandleExternalEventActivity activity, ActivityExecutionContext context, object msg, Type interfaceType, string operation) { IMethodMessage message = msg as IMethodMessage; if (message == null) { Exception excp = msg as Exception; if (excp != null) throw excp; throw new InvalidOperationException(SR.GetString(SR.Error_InvalidLocalServiceMessage)); } CorrelationService.InvalidateCorrelationToken(activity, interfaceType, operation, message.Args); IdentityContextData identityData = (IdentityContextData)message.LogicalCallContext.GetData(IdentityContextData.IdentityContext); ValidateRoles(activity, identityData.Identity); if (ProcessEventParameters(activity.ParameterBindings, message, interfaceType, operation)) return message.Args; return null; } private static bool ProcessEventParameters(WorkflowParameterBindingCollection parameters, IMethodMessage message, Type interfaceType, string operation) { bool isKnownSignature = false; if (parameters == null) return isKnownSignature; EventInfo eventInfo = interfaceType.GetEvent(operation); MethodInfo methodInfo = eventInfo.EventHandlerType.GetMethod("Invoke"); int index = 0; foreach (ParameterInfo formalParameter in methodInfo.GetParameters()) { if ((typeof(ExternalDataEventArgs).IsAssignableFrom(formalParameter.ParameterType))) { if (index == 1) isKnownSignature = true; } if (parameters.Contains(formalParameter.Name)) { WorkflowParameterBinding binding = parameters[formalParameter.Name]; binding.Value = message.Args[index]; } index++; } return isKnownSignature; } internal static void ValidateRoles(Activity activity, string identity) { DependencyProperty dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType().BaseType); if (dependencyProperty == null) dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType()); if (dependencyProperty == null) return; ActivityBind rolesBind = activity.GetBinding(dependencyProperty) as ActivityBind; if (rolesBind == null) return; WorkflowRoleCollection roles = rolesBind.GetRuntimeValue(activity) as WorkflowRoleCollection; if (roles == null) return; if (!roles.IncludesIdentity(identity)) throw new WorkflowAuthorizationException(activity.Name, identity); } } } // 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
- SocketStream.cs
- XMLSyntaxException.cs
- DataSourceCacheDurationConverter.cs
- Bits.cs
- OracleDateTime.cs
- NumericUpDownAcceleration.cs
- PropertyReferenceExtension.cs
- FormsAuthenticationModule.cs
- Transform3DGroup.cs
- ProjectionCamera.cs
- Utility.cs
- CodeExporter.cs
- RelationshipConstraintValidator.cs
- DataGridCommandEventArgs.cs
- ParseElementCollection.cs
- CheckoutException.cs
- TimeoutValidationAttribute.cs
- M3DUtil.cs
- DataServiceProviderMethods.cs
- XmlSerializationReader.cs
- Timer.cs
- ToolboxItemAttribute.cs
- ReadOnlyCollectionBase.cs
- XPathDescendantIterator.cs
- CollectionBuilder.cs
- RegistryKey.cs
- DependencyObjectValidator.cs
- ObjectListGeneralPage.cs
- SecurityToken.cs
- FormsAuthenticationModule.cs
- basemetadatamappingvisitor.cs
- PageStatePersister.cs
- ActivityDelegate.cs
- GeometryValueSerializer.cs
- PersonalizablePropertyEntry.cs
- GetCertificateRequest.cs
- DataGridViewColumn.cs
- Rect.cs
- InkCanvasSelection.cs
- DbBuffer.cs
- SupportingTokenListenerFactory.cs
- BitVector32.cs
- ApplicationId.cs
- QueryOperationResponseOfT.cs
- BrowsableAttribute.cs
- HtmlInputFile.cs
- SmtpAuthenticationManager.cs
- LinkedResourceCollection.cs
- TextSimpleMarkerProperties.cs
- XamlFilter.cs
- LinkDescriptor.cs
- CharacterString.cs
- StylusPointDescription.cs
- MetaChildrenColumn.cs
- StatusBarDrawItemEvent.cs
- TimeStampChecker.cs
- ValueTypeFixupInfo.cs
- DependencyObjectType.cs
- HttpHeaderCollection.cs
- SecurityHeader.cs
- Floater.cs
- PropertyAccessVisitor.cs
- HttpHandlersSection.cs
- EntityDataSourceSelectedEventArgs.cs
- SqlDataSourceSummaryPanel.cs
- DispatcherTimer.cs
- SmiMetaData.cs
- RelationshipSet.cs
- ParentUndoUnit.cs
- Listbox.cs
- JpegBitmapDecoder.cs
- SmiXetterAccessMap.cs
- ClientBuildManager.cs
- COMException.cs
- QueryOperationResponseOfT.cs
- UriParserTemplates.cs
- GrammarBuilderPhrase.cs
- TabControlToolboxItem.cs
- X509CertificateValidator.cs
- DataGridDesigner.cs
- GregorianCalendarHelper.cs
- FactoryRecord.cs
- Version.cs
- ColumnCollection.cs
- SQLBytesStorage.cs
- EnumValidator.cs
- FromReply.cs
- EntityTypeEmitter.cs
- AppDomain.cs
- RegisteredDisposeScript.cs
- HostProtectionException.cs
- Int64Converter.cs
- WebEncodingValidator.cs
- SqlAliaser.cs
- APCustomTypeDescriptor.cs
- WindowsGrip.cs
- LayoutEditorPart.cs
- GcHandle.cs
- ToolStripRenderEventArgs.cs
- XmlConvert.cs