Beispiel #1
0
        private async Task AssignInput <T>(T provider) where T : class, IInputProvider
        {
            if (_busy)
            {
                return;
            }
            _busy = true;

            try {
                var waiting = GetWaiting() as BaseEntry <T>;
                if (waiting == null)
                {
                    return;
                }

                if (waiting.Input == provider)
                {
                    waiting.Waiting = false;
                    return;
                }

                var existing = Entries.OfType <BaseEntry <T> >().Where(x => x.Input == provider).ToList();
                if (existing.Any())
                {
                    var solution = ConflictResolver == null ? AcControlsConflictSolution.ClearPrevious :
                                   await ConflictResolver.Resolve(provider.DisplayName, existing.Select(x => x.DisplayName));

                    switch (solution)
                    {
                    case AcControlsConflictSolution.Cancel:
                        return;

                    case AcControlsConflictSolution.Flip:
                        foreach (var entry in existing)
                        {
                            entry.Input = waiting.Input;
                        }
                        break;

                    case AcControlsConflictSolution.ClearPrevious:
                        foreach (var entry in existing)
                        {
                            entry.Clear();
                        }
                        break;
                    }
                }

                waiting.Input = provider;
            } finally {
                _busy = false;
            }
        }