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
- HandledEventArgs.cs
- Track.cs
- DecimalAnimationBase.cs
- ParameterReplacerVisitor.cs
- HtmlImage.cs
- SelectionBorderGlyph.cs
- EventLogPermissionEntry.cs
- EnumBuilder.cs
- HttpException.cs
- MediaPlayer.cs
- MasterPageBuildProvider.cs
- GenericAuthenticationEventArgs.cs
- ToolboxItemFilterAttribute.cs
- WCFServiceClientProxyGenerator.cs
- ComplexType.cs
- ActivitiesCollection.cs
- DataQuery.cs
- DllNotFoundException.cs
- HandlerBase.cs
- TrustManagerMoreInformation.cs
- HttpListenerPrefixCollection.cs
- RootBuilder.cs
- GlyphTypeface.cs
- TreeIterator.cs
- ServicePoint.cs
- DebugView.cs
- FactoryId.cs
- XsltOutput.cs
- SimpleLine.cs
- MutexSecurity.cs
- ContextInformation.cs
- DataFormats.cs
- ProtectedConfigurationProviderCollection.cs
- ValidationHelpers.cs
- VideoDrawing.cs
- HttpStreams.cs
- FlowDocumentScrollViewer.cs
- SectionRecord.cs
- CompilerError.cs
- DefaultAutoFieldGenerator.cs
- Addressing.cs
- RequestUriProcessor.cs
- WebConfigurationFileMap.cs
- Stylus.cs
- IndentedWriter.cs
- figurelength.cs
- SelectionChangedEventArgs.cs
- DataGridToolTip.cs
- DispatcherFrame.cs
- Exception.cs
- RunInstallerAttribute.cs
- TypeDependencyAttribute.cs
- SafeArrayRankMismatchException.cs
- DataGridColumnStyleMappingNameEditor.cs
- LineUtil.cs
- RemoteWebConfigurationHostServer.cs
- JumpPath.cs
- DefaultParameterValueAttribute.cs
- RelatedEnd.cs
- SymmetricAlgorithm.cs
- NativeCompoundFileAPIs.cs
- DesignerAdapterAttribute.cs
- CurrencyWrapper.cs
- WinInetCache.cs
- DataServiceHostFactory.cs
- DrawingGroupDrawingContext.cs
- ErrorHandler.cs
- ThousandthOfEmRealDoubles.cs
- DesignTable.cs
- TlsnegoTokenProvider.cs
- Stackframe.cs
- OutOfProcStateClientManager.cs
- NamespaceCollection.cs
- MdiWindowListStrip.cs
- SystemIPGlobalStatistics.cs
- DrawingContextWalker.cs
- ElementProxy.cs
- CodeDelegateInvokeExpression.cs
- XmlWriter.cs
- UIPropertyMetadata.cs
- SchemaMerger.cs
- GridItemPatternIdentifiers.cs
- FormsAuthenticationConfiguration.cs
- XmlSchemaRedefine.cs
- HttpInputStream.cs
- HtmlProps.cs
- EventLogException.cs
- XmlDataSource.cs
- SqlUserDefinedAggregateAttribute.cs
- FilteredDataSetHelper.cs
- DetailsViewInsertEventArgs.cs
- ContentTextAutomationPeer.cs
- ExpressionBuilderCollection.cs
- DbProviderFactory.cs
- SchemaSetCompiler.cs
- Animatable.cs
- Baml2006KeyRecord.cs
- RemotingConfigParser.cs
- AdPostCacheSubstitution.cs
- DataGridViewMethods.cs