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);
        }
Beispiel #2
0
        protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }
            if (this.InterfaceType == null)
            {
                throw new ArgumentException(
                          SR.GetString(SR.Error_MissingInterfaceType), "executionContext");
            }

            Type   type       = this.InterfaceType;
            string methodName = this.MethodName;

            object serviceValue = executionContext.GetService(type);

            if (serviceValue == null)
            {
                throw new InvalidOperationException(SR.GetString(SR.Error_ServiceNotFound, this.InterfaceType));
            }

            this.RaiseEvent(MethodInvokingEvent, this, EventArgs.Empty);
            OnMethodInvoking(EventArgs.Empty);

            MethodInfo methodInfo = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public);

            ParameterModifier[] parameterModifiers = null;
            object[]            actualParameters   = InvokeHelper.GetParameters(methodInfo, this.ParameterBindings, out parameterModifiers);

            WorkflowParameterBinding resultBinding = null;

            if (this.ParameterBindings.Contains("(ReturnValue)"))
            {
                resultBinding = this.ParameterBindings["(ReturnValue)"];
            }

            CorrelationService.InvalidateCorrelationToken(this, type, methodName, actualParameters);

            object result = type.InvokeMember(this.MethodName, BindingFlags.InvokeMethod, new ExternalDataExchangeBinder(), serviceValue, actualParameters, parameterModifiers, null, null);

            if (resultBinding != null)
            {
                resultBinding.Value = InvokeHelper.CloneOutboundValue(result, new BinaryFormatter(), "(ReturnValue)");
            }

            InvokeHelper.SaveOutRefParameters(actualParameters, methodInfo, this.ParameterBindings);
            OnMethodInvoked(EventArgs.Empty);
            return(ActivityExecutionStatus.Closed);
        }
Beispiel #3
0
        private void ProcessMessage(ActivityExecutionContext context, object msg, Type interfaceType, string operation)
        {
            IMethodMessage message = msg as IMethodMessage;

            if (message == null)
            {
                Exception exception = msg as Exception;
                if (exception != null)
                {
                    throw exception;
                }
                throw new ArgumentNullException("msg");
            }
            CorrelationService.InvalidateCorrelationToken(this, interfaceType, operation, message.Args);
            IdentityContextData data = (IdentityContextData)message.LogicalCallContext.GetData("__identitycontext__");

            InboundActivityHelper.ValidateRoles(this, data.Identity);
            this.ProcessParameters(context, message, interfaceType, operation);
            base.RaiseEvent(InputReceivedEvent, this, EventArgs.Empty);
        }