public override object Run(WorkFlowContext context, SearchMode mode, WorkFlow.Visitors.IVisitor visitor = null)
        {
            if (visitor == null)
                visitor = new DefaultVisitor();

            Queue<string> fila = new Queue<string>();
            List<string> mark = new List<string>();

            fila.Enqueue(context.SourceState);
            mark.Add(context.SourceState);

            while (fila.Count != 0)
            {
                string statusfila = fila.Dequeue();
                context.SourceState = statusfila;
                foreach (var item in this.GetActivities(context).OrderBy(x => x.Operation))
                {
                    context.Operation = item.Operation;
                    string newstatus = this.GetNextStatus(context);
                    visitor.Visit(statusfila, new Activity { Operation = item.Operation, Description = item.Description }, newstatus);

                    if (!mark.Contains(newstatus))
                    {
                        fila.Enqueue(newstatus);
                        mark.Add(newstatus);
                    }
                }
            }

            return visitor.EndVisit();
        }
Exemple #2
0
        public override object Run(WorkFlowContext context, SearchMode mode, IVisitor visitor = null)
        {
            if (visitor == null)
                visitor = new DefaultVisitor();

            if (mode == SearchMode.Depth)
            {
                RunInDepth(context, visitor);
            }
            else if (mode == SearchMode.Breadth)
            {
                RunInWidth(context, visitor);
            }

            return visitor.EndVisit();
        }