protected override void GatherOutputs(ActivityInstance completedInstance) { if (completedInstance.Activity.HandlerOf != null) { IList <RuntimeDelegateArgument> runtimeArguments = completedInstance.Activity.HandlerOf.RuntimeDelegateArguments; LocationEnvironment environment = completedInstance.Environment; for (int i = 0; i < runtimeArguments.Count; i++) { RuntimeDelegateArgument runtimeArgument = runtimeArguments[i]; if (runtimeArgument.BoundArgument != null) { if (ArgumentDirectionHelper.IsOut(runtimeArgument.Direction)) { Location parameterLocation = environment.GetSpecificLocation(runtimeArgument.BoundArgument.Id); if (parameterLocation != null) { if (_results == null) { _results = new Dictionary <string, object>(); } _results.Add(runtimeArgument.Name, parameterLocation.Value); } } } } } }
static bool CompareRuntimeDelegateArgumentEquality(RuntimeDelegateArgument newRuntimeDelegateArgument, RuntimeDelegateArgument oldRuntimeDelegateArgument) { // compare Name, Type and Direction if (!newRuntimeDelegateArgument.Name.Equals(oldRuntimeDelegateArgument.Name) || (newRuntimeDelegateArgument.Type != oldRuntimeDelegateArgument.Type) || (newRuntimeDelegateArgument.Direction != oldRuntimeDelegateArgument.Direction)) { return(false); } return(CompareDelegateArgumentEquality(newRuntimeDelegateArgument.BoundArgument, oldRuntimeDelegateArgument.BoundArgument)); }
protected override void CacheMetadata(NativeActivityMetadata metadata) { Collection <RuntimeArgument> arguments = new Collection <RuntimeArgument>(); foreach (KeyValuePair <string, Argument> pair in this.DelegateArguments) { RuntimeArgument argument = new RuntimeArgument(pair.Key, pair.Value.ArgumentType, pair.Value.Direction); metadata.Bind(pair.Value, argument); arguments.Add(argument); } metadata.SetArgumentsCollection(arguments); metadata.AddDelegate(this.Delegate); if (this.Delegate != null) { IList <RuntimeDelegateArgument> runtimeDelegateArguments = this.Delegate.RuntimeDelegateArguments; if (this.DelegateArguments.Count != runtimeDelegateArguments.Count) { metadata.AddValidationError(System.Activities.SR.WrongNumberOfArgumentsForActivityDelegate); } for (int i = 0; i < runtimeDelegateArguments.Count; i++) { RuntimeDelegateArgument argument2 = runtimeDelegateArguments[i]; Argument argument3 = null; string name = argument2.Name; if (this.DelegateArguments.TryGetValue(name, out argument3)) { if (argument3.Direction != argument2.Direction) { metadata.AddValidationError(System.Activities.SR.DelegateParameterDirectionalityMismatch(name, argument3.Direction, argument2.Direction)); } if (argument2.Direction == ArgumentDirection.In) { if (!TypeHelper.AreTypesCompatible(argument3.ArgumentType, argument2.Type)) { metadata.AddValidationError(System.Activities.SR.DelegateInArgumentTypeMismatch(name, argument2.Type, argument3.ArgumentType)); } } else if (!TypeHelper.AreTypesCompatible(argument2.Type, argument3.ArgumentType)) { metadata.AddValidationError(System.Activities.SR.DelegateOutArgumentTypeMismatch(name, argument2.Type, argument3.ArgumentType)); } } else { metadata.AddValidationError(System.Activities.SR.InputParametersMissing(argument2.Name)); } if (!this.hasOutputArguments && ArgumentDirectionHelper.IsOut(argument2.Direction)) { this.hasOutputArguments = true; } } } }
protected override void GatherOutputs(System.Activities.ActivityInstance completedInstance) { if (completedInstance.Activity.HandlerOf != null) { IList <RuntimeDelegateArgument> runtimeDelegateArguments = completedInstance.Activity.HandlerOf.RuntimeDelegateArguments; LocationEnvironment environment = completedInstance.Environment; for (int i = 0; i < runtimeDelegateArguments.Count; i++) { RuntimeDelegateArgument argument = runtimeDelegateArguments[i]; if ((argument.BoundArgument != null) && ArgumentDirectionHelper.IsOut(argument.Direction)) { Location specificLocation = environment.GetSpecificLocation(argument.BoundArgument.Id); if (specificLocation != null) { if (this.results == null) { this.results = new Dictionary <string, object>(); } this.results.Add(argument.Name, specificLocation.Value); } } } } }
protected override void CacheMetadata(NativeActivityMetadata metadata) { Collection <RuntimeArgument> arguments = new Collection <RuntimeArgument>(); foreach (KeyValuePair <string, Argument> entry in this.DelegateArguments) { RuntimeArgument argument = new RuntimeArgument(entry.Key, entry.Value.ArgumentType, entry.Value.Direction); metadata.Bind(entry.Value, argument); arguments.Add(argument); } metadata.SetArgumentsCollection(arguments); metadata.AddDelegate(this.Delegate); if (this.Delegate != null) { IList <RuntimeDelegateArgument> targetDelegateArguments = this.Delegate.RuntimeDelegateArguments; if (this.DelegateArguments.Count != targetDelegateArguments.Count) { metadata.AddValidationError(SR.WrongNumberOfArgumentsForActivityDelegate); } // Validate that the names and directionality of arguments in DelegateArguments dictionary // match the names and directionality of arguments returned by the ActivityDelegate.GetDelegateParameters // call above. for (int i = 0; i < targetDelegateArguments.Count; i++) { RuntimeDelegateArgument expectedParameter = targetDelegateArguments[i]; string parameterName = expectedParameter.Name; if (this.DelegateArguments.TryGetValue(parameterName, out Argument delegateArgument)) { if (delegateArgument.Direction != expectedParameter.Direction) { metadata.AddValidationError(SR.DelegateParameterDirectionalityMismatch(parameterName, delegateArgument.Direction, expectedParameter.Direction)); } if (expectedParameter.Direction == ArgumentDirection.In) { if (!TypeHelper.AreTypesCompatible(delegateArgument.ArgumentType, expectedParameter.Type)) { metadata.AddValidationError(SR.DelegateInArgumentTypeMismatch(parameterName, expectedParameter.Type, delegateArgument.ArgumentType)); } } else { if (!TypeHelper.AreTypesCompatible(expectedParameter.Type, delegateArgument.ArgumentType)) { metadata.AddValidationError(SR.DelegateOutArgumentTypeMismatch(parameterName, expectedParameter.Type, delegateArgument.ArgumentType)); } } } else { metadata.AddValidationError(SR.InputParametersMissing(expectedParameter.Name)); } if (!this.hasOutputArguments && ArgumentDirectionHelper.IsOut(expectedParameter.Direction)) { this.hasOutputArguments = true; } } } metadata.AddChild(this.Default); }
protected virtual void VisitDelegateArgument(RuntimeDelegateArgument delegateArgument, out bool exit) { // // Nothing further to walk into here, this is just a stub for implementors to override exit = false; }