This is a migrated thread and some comments may be shown as answers.

= Function() Do

0 Answers 43 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 20 Mar 2012, 04:07 AM

Here is a Snippet that seems to Fail to convert to VB correctly:
If you can do this one I have two more from the same project that also fail.
As you may note in the Imports statements - this conversion is taken from a Caliburn Micro learning sample project

Bob


namespace HelloScreensWPF.Shell {
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Framework;
    using Caliburn.Micro;

    public class ApplicationCloseStrategy : ICloseStrategy<IWorkspace> {
        IEnumerator<IWorkspace> enumerator;
        bool finalResult;
        Action<bool, IEnumerable<IWorkspace>> callback;

        public void Execute(IEnumerable<IWorkspace> toClose, Action<bool, IEnumerable<IWorkspace>> callback) {
            enumerator = toClose.GetEnumerator();
            this.callback = callback;
            finalResult = true;

            Evaluate(finalResult);
        }

        void Evaluate(bool result)
        {
            finalResult = finalResult && result;

            if (!enumerator.MoveNext() || !result)
                callback(finalResult, new List<IWorkspace>());
            else
            {
                var current = enumerator.Current;
                var conductor = current as IConductor;
                if (conductor != null)
                {
                    var tasks = conductor.GetChildren()
                        .OfType<IHaveShutdownTask>()
                        .Select(x => x.GetShutdownTask())
                        .Where(x => x != null);

                    var sequential = new SequentialResult(tasks.GetEnumerator());
                    sequential.Completed += (s, e) => {
                        if(!e.WasCancelled)
                        Evaluate(!e.WasCancelled);
                    };
                    sequential.Execute(new ActionExecutionContext());
                }
                else Evaluate(true);
            }
        }
    }
}

No answers yet. Maybe you can help?

Tags
Ajax
Asked by
Bob
Top achievements
Rank 1
Share this question
or