コード例 #1
0
        /// <summary>Add a listener to the list.</summary>
        /// <remarks>Add a listener to the list.</remarks>
        /// <?></?>
        /// <param name="type">type of listener being registered.</param>
        /// <param name="listener">the listener instance.</param>
        /// <returns>a handle to later remove the registration, if desired.</returns>
        public virtual ListenerHandle AddListener <T>(T listener) where T : RepositoryListener
        {
            System.Type    type   = typeof(T);
            ListenerHandle handle = new ListenerHandle(this, type, listener);

            Add(handle);
            return(handle);
        }
コード例 #2
0
        internal virtual void Remove(ListenerHandle handle)
        {
            IList <ListenerHandle> list = lists.Get(handle.type);

            if (list != null)
            {
                list.Remove(handle);
            }
        }
コード例 #3
0
        private void Add(ListenerHandle handle)
        {
            IList <ListenerHandle> list = lists.Get(handle.type);

            if (list == null)
            {
                CopyOnWriteArrayList <ListenerHandle> newList;
                newList = new CopyOnWriteArrayList <ListenerHandle>();
                list    = lists.PutIfAbsent(handle.type, newList);
                if (list == null)
                {
                    list = newList;
                }
            }
            list.AddItem(handle);
        }