public virtual void AddAction(WorkDefine.ActionDefinition toAdd) { WorkDefine.ActionDefinition match = this.GetActionDefinition(toAdd.Id); if (match == null) { this.WorkFlow.Actions.Add(toAdd); } }
private void LoadActivity(WorkDefine.Workflow workFlow, string activityId) { WorkDefine.Activity definition = workFlow.Activities.FirstOrDefault(a => a.Id == activityId); Action <WorkDefine.Activity, bool> LoadReactions = null; LoadReactions = (d, isroot) => { if (d.Reactions != null && d.Reactions.Count > 0) { d.Reactions.ForEach(r => { WorkDefine.Activity toCreatedef = workFlow.Activities.FirstOrDefault(z => z.Id == r.Work); if (null == toCreatedef) { //if we can't find activity... look for a matching action. if found, create an activity from it. WorkDefine.ActionRef asActionRef = r.Work; WorkDefine.ActionDefinition toCreateAction = workFlow.Actions.FirstOrDefault(z => z.Id == asActionRef.Id); //didn't bother to add the action definition, we will create it for them if (null == toCreateAction) { workFlow.Actions.Add(new WorkDefine.ActionDefinition() { Id = asActionRef.Id, Description = "" }); } toCreatedef = new WorkDefine.Activity() { //Action = asActionRef, Id = Guid.NewGuid().ToString(), Reactions = new List <WorkDefine.Reaction>() }; } if (string.IsNullOrEmpty(r.Logic)) { r.Logic = ConventionHelper.TrueEquation(this.config.Convention); } r.Logic = LoadLogic(workFlow, r.Logic); LoadReactions(toCreatedef, false); }); } }; LoadReactions(definition, true); }
private void Do(Action <IActionBuilder <T> > builder, Func <WorkDefine.ActionDefinition> overrideName = null) { ActionBuilder <T> builderRef = new ActionBuilder <T>(this); builder.Invoke(builderRef); WorkDefine.ActionRef ToDo = builderRef.actionRef; WorkDefine.ActionDefinition actionDef = new ActionDefinition(); if (overrideName != null) { actionDef = overrideName(); actionDef.Id = ConventionHelper.EnsureConvention(NamePrefixOptions.Action, actionDef.Id, this.config.Convention); ToDo = actionDef.Id; } else { ToDo.Id = ConventionHelper.EnsureConvention(NamePrefixOptions.Action, ToDo.Id, this.config.Convention); string actionName = builderRef.action.GetType().Name; string description = ConventionHelper.ParseMethodName(actionName, this.config.Convention.ParseMethodNamesAs).Literal; var descAttr = builderRef.action.GetType().GetCustomAttributes(typeof(ArticulateOptionsAttribute), true) .OfType <ArticulateOptionsAttribute>() .FirstOrDefault(); if (descAttr != null) { description = descAttr.Description; } actionDef = new WorkDefine.ActionDefinition() { Id = ToDo.Id, Description = description }; } this.workflowManager.AddAction(actionDef); if (!this.actions.ContainsKey(ToDo.Id)) { this.actions.Add(ToDo.Id, builderRef.action); } else { //if attmpeting to add another implementation with the same id, throw an exception //we can't handle this if ((this.actions[ToDo.Id].GetType()) != builderRef.action.GetType()) { throw new BuilderException(ToDo.Id); } } this.created = ToDo; }
public IAction <TModel> getAction(WorkDefine.ActionDefinition def) { WorkDefine.ActionDefinition withoutConvention = new WorkDefine.ActionDefinition() { Id = ConventionHelper.RemoveConvention(def.Id, this.Configuration.Convention), Description = def.Description }; IAction <TModel> toReturn = default(IAction <TModel>); if (this.actions.ContainsKey(withoutConvention.Id)) { toReturn = this.actions[withoutConvention.Id]; } else { toReturn = this.actions[def.Id]; } return(toReturn); }
//internal ImplementationManager(IWorkflowBuilderFactory definitionFactory, Configuration.Config configuration) : this(configuration) //{ // this.ActionFactory.Configuration = configuration; // this.EvaluatorFactory.Configuration = configuration; // this.DefinitionFactory = definitionFactory; //} public virtual IAction <TModel> GetAction(WorkDefine.ActionDefinition def) { return(this.ActionFactory.getAction(def)); }
public IAction <TModel> GetAction(WorkDefine.ActionDefinition def) { return(this.af.GetAction <TModel>(def)); }
public virtual WorkDefine.ActionDefinition GetActionDefinition(string id) { WorkDefine.ActionDefinition match = this.WorkFlow.Actions.FirstOrDefault(z => z.Id == id); return(match); }
public FakeAction(ActionDefinition definition) { this.Definition = definition; }