protected override void CacheMetadata(NativeActivityMetadata metadata) { if (GetBatchingStrategyFactory.IsNull()) metadata.AddValidationError("GetBatchingStrategyFactory function is expected."); if (GetNextVectors.IsNull()) metadata.AddValidationError("GetNextVectors function is expected."); if (ItemCount == null) metadata.AddValidationError("ItemCount expression expected."); metadata.AddDelegate(GetBatchingStrategyFactory); metadata.AddDelegate(GetNextVectors); metadata.AddDelegate(ReinitializeVectorProvider); RuntimeArgument arg; metadata.AddArgument(arg = new RuntimeArgument("LastResult", typeof(BatchExecutionResult), ArgumentDirection.In)); metadata.Bind(LastResult, arg); metadata.AddArgument(arg = new RuntimeArgument("ReinitializationFrequency", typeof(int), ArgumentDirection.In)); metadata.Bind(ReinitializationFrequency, arg); metadata.AddArgument(arg = new RuntimeArgument("UseCache", typeof(bool), ArgumentDirection.In)); metadata.Bind(UseCache, arg); metadata.AddChild(ItemCount); metadata.AddImplementationVariable(cachedVectors); metadata.AddImplementationVariable(strategyHasJustInited); base.CacheMetadata(metadata); }
/// <summary> /// Create internal states /// </summary> public static void ProcessChildStates(NativeActivityMetadata metadata, Collection<State> childStates, Collection<InternalState> internalStates, Collection<ActivityFunc<string, StateMachineEventManager, string>> internalStateFuncs) { foreach (State state in childStates) { InternalState internalState = state.InternalState; internalStates.Add(internalState); DelegateInArgument<string> toStateId = new DelegateInArgument<string>(); DelegateInArgument<StateMachineEventManager> eventManager = new DelegateInArgument<StateMachineEventManager>(); internalState.ToState = toStateId; internalState.EventManager = eventManager; ActivityFunc<string, StateMachineEventManager, string> activityFunc = new ActivityFunc<string, StateMachineEventManager, string> { Argument1 = toStateId, Argument2 = eventManager, Handler = internalState, }; if (state.Reachable) { //If this state is not reached, we should not add it as child because it's even not well validated. metadata.AddDelegate(activityFunc); } internalStateFuncs.Add(activityFunc); } }
protected override void CacheMetadata(NativeActivityMetadata metadata) { if (GetNextVectors.IsNull()) metadata.AddValidationError("GetNextVectors function is expected."); base.CacheMetadata(metadata); metadata.AddDelegate(GetNextVectors); metadata.AddImplementationVariable(vectorList); }
protected override void CacheMetadata(NativeActivityMetadata metadata) { RuntimeArgument valuesArgument = new RuntimeArgument("Values", typeof(IEnumerable), ArgumentDirection.In, true); metadata.Bind(this.Values, valuesArgument); metadata.AddArgument(valuesArgument); metadata.AddDelegate(this.Body); metadata.AddImplementationVariable(this.valueEnumerator); }
protected override void CacheMetadata(NativeActivityMetadata metadata) { base.CacheMetadata(metadata); if (Body.IsNull()) metadata.AddValidationError("Body is required."); metadata.AddDelegate(Body); if (Condition == null) metadata.AddValidationError("Condition is required."); metadata.AddChild(Condition); }
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 CacheMetadata(NativeActivityMetadata metadata) { RuntimeArgument argument = new RuntimeArgument("Values", typeof(IEnumerable <T>), ArgumentDirection.In, true); metadata.Bind(this.Values, argument); metadata.SetArgumentsCollection(new Collection <RuntimeArgument> { argument }); if (this.CompletionCondition != null) { metadata.SetChildrenCollection(new Collection <Activity> { this.CompletionCondition }); } if (this.CompletionCondition != null) { if (this.hasCompleted == null) { this.hasCompleted = new Variable <bool>(); } metadata.AddImplementationVariable(this.hasCompleted); } metadata.AddDelegate(this.Body); }
protected override void CacheMetadata(NativeActivityMetadata metadata) { // Tell the runtime that we need this extension metadata.RequireExtension(typeof(Hosting.FileCopyExtension)); // Provide a Func<T> to create the extension if it does not already exist metadata.AddDefaultExtensionProvider(() => new Hosting.FileCopyExtension()); if (this.StepIncrement < 0 || this.StepIncrement > 100) { metadata.AddValidationError(Properties.Resources.StepIncrementOutOfRange); } if (this.OnProgress != null) { metadata.AddDelegate(this.OnProgress); } metadata.AddImplementationVariable(this.noPersistHandle); metadata.AddImplementationVariable(this.bookmarkProgress); metadata.AddArgument(new RuntimeArgument("Source", typeof(string), ArgumentDirection.In, true)); metadata.AddArgument(new RuntimeArgument("Target", typeof(string), ArgumentDirection.In, true)); }
protected override void CacheMetadata(NativeActivityMetadata metadata) { metadata.AddDelegate(this.Action); }
protected override void CacheMetadata(NativeActivityMetadata metadata) { // Tell the runtime that we need this extension metadata.RequireExtension(typeof(Hosting.FileCopyExtension)); // Provide a Func<T> to create the extension if it does not already exist metadata.AddDefaultExtensionProvider(() => new Hosting.FileCopyExtension()); if (this.StepIncrement < 0 || this.StepIncrement > 100) metadata.AddValidationError(Properties.Resources.StepIncrementOutOfRange); if (this.OnProgress != null) metadata.AddDelegate(this.OnProgress); metadata.AddImplementationVariable(this.noPersistHandle); metadata.AddImplementationVariable(this.bookmarkProgress); metadata.AddArgument(new RuntimeArgument("Source", typeof(string), ArgumentDirection.In, true)); metadata.AddArgument(new RuntimeArgument("Target", typeof(string), ArgumentDirection.In, true)); }
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 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]; Argument delegateArgument = null; string parameterName = expectedParameter.Name; if (this.DelegateArguments.TryGetValue(parameterName, out 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); }
/// <summary> /// Creates and validates a description of the activity's arguments, variables, child activities, and activity delegates. /// </summary> /// <param name="metadata">The activity's metadata that encapsulates the activity's arguments, variables, child activities, and activity delegates.</param> protected override void CacheMetadata(NativeActivityMetadata metadata) { // Add a validation error if the Operation is not defined. if (this.Operation == null) { metadata.AddValidationError("AzureAsyncOperation requires an Azure activity to execute."); return; } // Add the publicly defined activities as children. metadata.AddChild(this.Operation); metadata.AddChild(this.Success); metadata.AddChild(this.Failure); // Define internal variables. metadata.AddImplementationVariable(this.PollingEndTime); metadata.AddImplementationVariable(this.OperationId); metadata.AddImplementationVariable(this.AzureActivityExceptionCaught); // Define public arguments. var thumbArgument = new RuntimeArgument("CertificateThumbprintId", typeof(string), ArgumentDirection.In); metadata.Bind(this.CertificateThumbprintId, thumbArgument); metadata.AddArgument(thumbArgument); var subArgument = new RuntimeArgument("SubscriptionId", typeof(string), ArgumentDirection.In); metadata.Bind(this.SubscriptionId, subArgument); metadata.AddArgument(subArgument); // Add our activities as delegates. metadata.AddDelegate(this.PollingBody); metadata.AddDelegate(this.DelayBody); }
protected override void CacheMetadata(NativeActivityMetadata metadata) { RuntimeArgument valuesArgument = new RuntimeArgument("Values", typeof(IEnumerable), ArgumentDirection.In, true); metadata.Bind(this.Values, valuesArgument); metadata.SetArgumentsCollection(new Collection<RuntimeArgument> { valuesArgument }); // declare the CompletionCondition as a child if (this.CompletionCondition != null) { metadata.SetChildrenCollection(new Collection<Activity> { this.CompletionCondition }); } // declare the hasCompleted variable if (this.CompletionCondition != null) { if (this.hasCompleted == null) { this.hasCompleted = new Variable<bool>(); } metadata.AddImplementationVariable(this.hasCompleted); } metadata.AddDelegate(this.Body); }
/// <summary> /// The cache metadata. /// </summary> /// <param name="metadata"> /// The metadata. /// </param> protected override void CacheMetadata(NativeActivityMetadata metadata) { metadata.RequireExtension<IHttpWorkflowHostContext>(); metadata.AddDelegate(this.Body); metadata.AddImplementationVariable(this.noPersistHandle); metadata.AddImplementationChild(this.persist); }
private void ProcessStates(NativeActivityMetadata metadata) { foreach (System.Activities.Statements.State state in this.states.Distinct<System.Activities.Statements.State>()) { InternalState internalState = state.InternalState; this.internalStates.Add(internalState); DelegateInArgument<StateMachineEventManager> argument = new DelegateInArgument<StateMachineEventManager>(); internalState.EventManager = argument; ActivityFunc<StateMachineEventManager, string> activityDelegate = new ActivityFunc<StateMachineEventManager, string> { Argument = argument, Handler = internalState }; if (state.Reachable) { metadata.AddDelegate(activityDelegate); } this.internalStateFuncs.Add(activityDelegate); } }
protected override void CacheMetadata(NativeActivityMetadata metadata) { metadata.AddDelegate(ApplyActivityFunc); base.CacheMetadata(metadata); }