コード例 #1
0
 public static void Execute(Binding[] bindings)
 {
     Instance.ExecuteInternal(bindings);
 }
コード例 #2
0
        private void ExecuteInternal(Binding[] bindings)
        {
            foreach (var binding in bindings)
            {
                if (!binding.IsScheduled)
                {
                    _scheduledBindings.Enqueue(new ScheduledBinding(binding, _executingBinding));
                    binding.IsScheduled = true;
                    _tracer?.Invoke(string.Format("Scheduled binding {0}", binding.DebugContext.Description));
                }
                else
                {
                    _tracer?.Invoke(string.Format("Ignored binding {0}", binding.DebugContext.Description));
                }
            }

            if (_executingBinding == null)
            {
                try
                {
                    while (_scheduledBindings.Count > 0)
                    {
                        _executingBinding = _scheduledBindings.Dequeue();
                        _executingBinding.Binding.IsScheduled = false;
                        _tracer?.Invoke(string.Format("Executing binding {0}", _executingBinding.Binding.DebugContext.Description));
                        if (Binder.DebugMode)
                        {
                            ExecuteWithVirtualStack();
                        }
                        else
                        {
                            _executingBinding.Binding.Execute();
                        }
                    }
                }
                catch (Exception)
                {
                    foreach (var tp in _scheduledBindings)
                    {
                        tp.Binding.IsScheduled = false;
                    }
                    _scheduledBindings.Clear();
                    throw;
                }
                finally
                {
                    _executingBinding = null;
                }
            }
        }
コード例 #3
0
 public ScheduledBinding(Binding binding, ScheduledBinding parent)
 {
     Binding = binding;
     Parent = parent;
 }