/// <summary> /// Adds a new <see cref="Action"/> instance to the task. /// </summary> /// <param name="actionType">Type of task to be created</param> /// <returns>Specialized <see cref="Action"/> instance.</returns> public Action AddNew(TaskActionType actionType) { if (v1Task != null) { return(new ExecAction(v1Task)); } return(Action.CreateAction(v2Coll.Create(actionType))); }
internal virtual void Bind(V2Interop.ITaskDefinition iTaskDef) { V2Interop.IActionCollection iActions = iTaskDef.Actions; switch (this.GetType().Name) { case "ComHandlerAction": iAction = iActions.Create(TaskActionType.ComHandler); break; case "ExecAction": iAction = iActions.Create(TaskActionType.Execute); break; case "EmailAction": iAction = iActions.Create(TaskActionType.SendEmail); break; case "ShowMessageAction": iAction = iActions.Create(TaskActionType.ShowMessage); break; default: throw new ArgumentException(); } Marshal.ReleaseComObject(iActions); foreach (string key in unboundValues.Keys) { try { iAction.GetType().InvokeMember(key, System.Reflection.BindingFlags.SetProperty, null, iAction, new object[] { unboundValues[key] }); } catch (System.Reflection.TargetInvocationException tie) { throw tie.InnerException; } catch { } } unboundValues.Clear(); }
public Action AddNew(TaskActionType actionType) { if (Count >= MaxActions) { throw new ArgumentOutOfRangeException(nameof(actionType), "A maximum of 32 actions is allowed within a single task."); } if (v1Task != null) { if (!SupportV1Conversion && (v1Actions.Count >= 1 || actionType != TaskActionType.Execute)) { throw new NotV1SupportedException($"Only a single {nameof(ExecAction)} is supported unless the {nameof(PowerShellConversion)} property includes the {nameof(PowerShellActionPlatformOption.Version1)} value."); } return(Action.CreateAction(v1Task)); } return(Action.CreateAction(v2Coll.Create(actionType))); }