Beispiel #1
0
        public void Execute(IDataContext dataContext, DelegateExecute nextExecute)
        {
            using (ReadLockCookie.Create())
            {
                var solution = dataContext.GetData(ProjectModelDataConstants.SOLUTION);
                if (solution == null)
                {
                    nextExecute();
                    return;
                }

                using (CompilationContextCookie.Create(GetResolveContext(dataContext, solution)))
                {
                    // The real code creates a modal loop here, so can use the data
                    // We use a modeless loop, so make sure the data context lasts
                    // for longer
                    var dataContextLifetimeDefinition = Lifetimes.Define(lifetime);
                    var extendedContext = dataContext.Prolongate(dataContextLifetimeDefinition.Lifetime);

                    var toExecute = GetWorkflowListToExecute(extendedContext);
                    if (toExecute == null || toExecute.Count == 0)
                    {
                        dataContextLifetimeDefinition.Terminate();
                        nextExecute();
                        return;
                    }

                    if (toExecute.HasMoreThan(1) || handler.ShowMenuWithOneItem)
                    {
                        ExecuteGroup(extendedContext, toExecute, dataContextLifetimeDefinition);
                        return;
                    }

                    handler.Execute(extendedContext, toExecute.Single().First);
                    dataContextLifetimeDefinition.Terminate();
                }
            }
        }