예제 #1
0
            /// <summary>
            /// Adiciona um observer para a entrada.
            /// </summary>
            /// <param name="observer"></param>
            /// <returns>Entrada gerada para o observer.</returns>
            public RecordObserverEntry AddObserver(IRecordObserver observer)
            {
                var entry = new RecordObserverEntry(observer);

                entry.Removed += ObserverEntryRemoved;
                lock (_observers)
                    _observers.Add(entry);
                return(entry);
            }
예제 #2
0
            /// <summary>
            /// Remove o observer associado.
            /// </summary>
            /// <param name="recordObserver">Instancia do observer que será removido.</param>
            /// <returns>True se for removido com sucesso.</returns>
            public bool RemoveObserver(IRecordObserver recordObserver)
            {
                if (recordObserver == null)
                {
                    return(false);
                }
                RecordObserverEntry entry = null;

                lock (_recordObserverEntries)
                    if (_recordObserverEntries.TryGetValue(recordObserver.Uid, out entry))
                    {
                        return(false);
                    }
                if (entry != null)
                {
                    _recordObserverEntries.Remove(recordObserver.Uid);
                    entry.Remove();
                    return(true);
                }
                return(false);
            }