示例#1
0
        public bool RemoveEntryMatchingObject(object obj)
        {
            if (null == obj)
            {
                return(false);
            }
            var keyToRemove = new EquatableWeakReference <object>(obj);

            return(_collection.TryRemove(keyToRemove, out _));
        }
示例#2
0
        public void Insert(RevokeContext context)
        {
            if (context == null)
            {
                throw new NullReferenceException("RevokeContext can not be null");
            }
            var revokee = context.Revokee;

            if (revokee != null)
            {
                var key   = new EquatableWeakReference <object>(revokee);
                var value = context;

                //Override
                _collection.AddOrUpdate(key, value, (_, __) => value);
            }
        }