Exemplo n.º 1
0
        private void AdicionarInscricaoInterna(Type tipoManipulador, string nomeEvento)
        {
            if (!ExisteInscricaoParaEvento(nomeEvento))
            {
                _manipuladores.Add(nomeEvento, new List <InformacaoInscricao>());
            }

            if (_manipuladores[nomeEvento].Any(s => s.TipoManipulador == tipoManipulador))
            {
                throw new ArgumentException(
                          $"Manipulador do tipo {tipoManipulador.Name} já registrado para '{nomeEvento}'", nameof(tipoManipulador));
            }

            _manipuladores[nomeEvento].Add(InformacaoInscricao.Criar(tipoManipulador));
        }
Exemplo n.º 2
0
        private void RemoverManipuladorInterno(string nomeEvento, InformacaoInscricao assinaturasParaRemover)
        {
            if (assinaturasParaRemover == null)
            {
                return;
            }

            _manipuladores[nomeEvento].Remove(assinaturasParaRemover);

            if (!_manipuladores[nomeEvento].Any())
            {
                _manipuladores.Remove(nomeEvento);

                var tipoEvento = _tiposEventos.SingleOrDefault(e => e.Name == nomeEvento);

                if (tipoEvento != null)
                {
                    _tiposEventos.Remove(tipoEvento);
                }

                DispararAoRemoverEvento(nomeEvento);
            }
        }