public void RemoveEventHandler(T handler)
        {
            if ((object)handler == null)
            {
                return;
            }
            lock (this.m_tokens)
            {
                EventRegistrationToken local_2 = EventRegistrationTokenTable <T> .GetPreferredToken(handler);

                T local_3;
                if (this.m_tokens.TryGetValue(local_2, out local_3) && (object)local_3 == (object)handler)
                {
                    this.RemoveEventHandlerNoLock(local_2);
                }
                else
                {
                    foreach (KeyValuePair <EventRegistrationToken, T> item_0 in this.m_tokens)
                    {
                        if ((object)item_0.Value == (object)handler)
                        {
                            this.RemoveEventHandlerNoLock(item_0.Key);
                            break;
                        }
                    }
                }
            }
        }
        public void RemoveEventHandler(T handler)
        {
            if (handler == null)
            {
                return;
            }
            Dictionary <EventRegistrationToken, T> tokens = this.m_tokens;

            lock (tokens)
            {
                EventRegistrationToken preferredToken = EventRegistrationTokenTable <T> .GetPreferredToken(handler);

                T t;
                if (this.m_tokens.TryGetValue(preferredToken, out t) && t == handler)
                {
                    this.RemoveEventHandlerNoLock(preferredToken);
                }
                else
                {
                    foreach (KeyValuePair <EventRegistrationToken, T> keyValuePair in this.m_tokens)
                    {
                        if (keyValuePair.Value == (T)((object)handler))
                        {
                            this.RemoveEventHandlerNoLock(keyValuePair.Key);
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        // void PropertyChanged.remove(EventRegistrationToken token)
        private void remove_CanExecuteChanged(EventRegistrationToken token)
        {
            ICommand _this = Unsafe.As <ICommand>(this);
            EventRegistrationTokenTable <EventHandler> table = s_weakTable.GetOrCreateValue(_this);

            if (table.RemoveEventHandler(token, out EventHandler handler))
            {
                _this.CanExecuteChanged -= handler;
            }
        }
Exemplo n.º 4
0
        // void PropertyChanged.remove(EventRegistrationToken token)
        internal void remove_PropertyChanged(EventRegistrationToken token)
        {
            INotifyPropertyChanged _this = Unsafe.As <INotifyPropertyChanged>(this);
            EventRegistrationTokenTable <PropertyChangedEventHandler> table = s_weakTable.GetOrCreateValue(_this);

            if (table.RemoveEventHandler(token, out PropertyChangedEventHandler handler))
            {
                _this.PropertyChanged -= handler;
            }
        }
Exemplo n.º 5
0
        // EventRegistrationToken PropertyChanged.add(PropertyChangedEventHandler value)
        internal EventRegistrationToken add_PropertyChanged(PropertyChangedEventHandler value)
        {
            INotifyPropertyChanged _this = Unsafe.As<INotifyPropertyChanged>(this);
            EventRegistrationTokenTable<PropertyChangedEventHandler> table = s_weakTable.GetOrCreateValue(_this);

            EventRegistrationToken token = table.AddEventHandler(value);
            _this.PropertyChanged += value;

            return token;
        }
Exemplo n.º 6
0
        internal EventRegistrationToken add_CollectionChanged(NotifyCollectionChangedEventHandler value)
        {
            INotifyCollectionChanged _this = JitHelpers.UnsafeCast <INotifyCollectionChanged>(this);
            EventRegistrationTokenTable <NotifyCollectionChangedEventHandler> table = m_weakTable.GetOrCreateValue(_this);

            EventRegistrationToken token = table.AddEventHandler(value);

            _this.CollectionChanged += value;

            return(token);
        }
Exemplo n.º 7
0
        // EventRegistrationToken PropertyChanged.add(EventHandler<object> value)
        private EventRegistrationToken add_CanExecuteChanged(EventHandler<object> value)
        {
            ICommand _this = Unsafe.As<ICommand>(this);
            EventRegistrationTokenTable<EventHandler> table = s_weakTable.GetOrCreateValue(_this);

            EventHandler handler = ICommandAdapterHelpers.CreateWrapperHandler(value);
            EventRegistrationToken token = table.AddEventHandler(handler);
            _this.CanExecuteChanged += handler;

            return token;
        }
Exemplo n.º 8
0
        // void PropertyChanged.remove(EventRegistrationToken token)
        private void remove_CanExecuteChanged(EventRegistrationToken token)
        {
            ICommand _this = JitHelpers.UnsafeCast <ICommand>(this);
            EventRegistrationTokenTable <EventHandler> table = m_weakTable.GetOrCreateValue(_this);

            EventHandler handler = table.ExtractHandler(token);

            if (handler != null)
            {
                _this.CanExecuteChanged -= handler;
            }
        }
Exemplo n.º 9
0
        internal void remove_PropertyChanged(EventRegistrationToken token)
        {
            INotifyPropertyChanged _this = JitHelpers.UnsafeCast <INotifyPropertyChanged>(this);
            EventRegistrationTokenTable <PropertyChangedEventHandler> table = m_weakTable.GetOrCreateValue(_this);

            PropertyChangedEventHandler handler = table.ExtractHandler(token);

            if (handler != null)
            {
                _this.PropertyChanged -= handler;
            }
        }
Exemplo n.º 10
0
        // void CollectionChanged.remove(EventRegistrationToken token)
        internal void remove_CollectionChanged(EventRegistrationToken token)
        {
            INotifyCollectionChanged _this = Unsafe.As <INotifyCollectionChanged>(this);
            EventRegistrationTokenTable <NotifyCollectionChangedEventHandler> table = s_weakTable.GetOrCreateValue(_this);

            NotifyCollectionChangedEventHandler handler = table.ExtractHandler(token);

            if (handler != null)
            {
                _this.CollectionChanged -= handler;
            }
        }
        private EventRegistrationToken AddEventHandlerNoLock(T handler)
        {
            EventRegistrationToken key = EventRegistrationTokenTable <T> .GetPreferredToken(handler);

            while (this.m_tokens.ContainsKey(key))
            {
                key = new EventRegistrationToken(key.Value + 1UL);
            }
            this.m_tokens[key] = handler;
            this.m_invokeList  = (T)Delegate.Combine((Delegate)(object)this.m_invokeList, (Delegate)(object)handler);
            return(key);
        }
        // Token: 0x0600635E RID: 25438 RVA: 0x00151CD4 File Offset: 0x0014FED4
        private EventRegistrationToken AddEventHandlerNoLock(T handler)
        {
            EventRegistrationToken preferredToken = EventRegistrationTokenTable <T> .GetPreferredToken(handler);

            while (this.m_tokens.ContainsKey(preferredToken))
            {
                preferredToken = new EventRegistrationToken(preferredToken.Value + 1UL);
            }
            this.m_tokens[preferredToken] = handler;
            Delegate @delegate = (Delegate)((object)this.m_invokeList);

            @delegate         = Delegate.Combine(@delegate, (Delegate)((object)handler));
            this.m_invokeList = (T)((object)@delegate);
            return(preferredToken);
        }
 public static EventRegistrationTokenTable <T> GetOrCreateEventRegistrationTokenTable(ref EventRegistrationTokenTable <T> refEventTable)
 {
     if (refEventTable == null)
     {
         Interlocked.CompareExchange <EventRegistrationTokenTable <T> >(ref refEventTable, new EventRegistrationTokenTable <T>(), null);
     }
     return(refEventTable);
 }
 public static EventRegistrationTokenTable <T> GetOrCreateEventRegistrationTokenTable(ref EventRegistrationTokenTable <T>?refEventTable)
 {
     if (refEventTable == null)
     {
         Interlocked.CompareExchange(ref refEventTable, new EventRegistrationTokenTable <T>(), null);
     }
     return(refEventTable !); // TODO-NULLABLE: Remove ! when compiler specially-recognizes CompareExchange for nullability
 }
Exemplo n.º 15
0
 public static EventRegistrationTokenTable <T> GetOrCreateEventRegistrationTokenTable(ref EventRegistrationTokenTable <T>?refEventTable)
 {
     if (refEventTable == null)
     {
         Interlocked.CompareExchange(ref refEventTable, new EventRegistrationTokenTable <T>(), null);
     }
     return(refEventTable !); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
 }
Exemplo n.º 16
0
 public static EventRegistrationTokenTable <T> GetOrCreateEventRegistrationTokenTable(ref EventRegistrationTokenTable <T> refEventTable)
 {
     throw new NotImplementedException();
 }