private MethodResolver CreateMethodResolver() { MethodResolver resolver = new MethodResolver { MethodName = this.MethodName, RunAsynchronously = this.RunAsynchronously, TargetType = this.TargetType, TargetObject = this.TargetObject, GenericTypeArguments = this.GenericTypeArguments, Parameters = this.Parameters, Result = _resultArgument, Parent = this }; if (this.Result != null) { resolver.ResultType = this.Result.ArgumentType; } else { resolver.ResultType = typeof(object); } return(resolver); }
protected override void CacheMetadata(CodeActivityMetadata metadata) { Collection <RuntimeArgument> arguments = new Collection <RuntimeArgument>(); Type targetObjectType = TypeHelper.ObjectType; if (this.TargetObject != null) { targetObjectType = this.TargetObject.ArgumentType; } RuntimeArgument targetObjectArgument = new RuntimeArgument("TargetObject", targetObjectType, ArgumentDirection.In); metadata.Bind(this.TargetObject, targetObjectArgument); arguments.Add(targetObjectArgument); Type resultType = TypeHelper.ObjectType; if (this.Result != null) { resultType = this.Result.ArgumentType; } _resultArgument = new RuntimeArgument("Result", resultType, ArgumentDirection.Out); metadata.Bind(this.Result, _resultArgument); arguments.Add(_resultArgument); // Parameters are named according to MethodInfo name if DetermineMethodInfo // succeeds, otherwise arbitrary names are used. _methodResolver = CreateMethodResolver(); _methodResolver.DetermineMethodInfo(metadata, s_funcCache, s_locker, ref _methodExecutor); _methodResolver.RegisterParameters(arguments); metadata.SetArgumentsCollection(arguments); _methodResolver.Trace(); if (_methodExecutor != null) { _methodExecutor.Trace(this); } }