コード例 #1
0
        public bool GetAndRemove(int id, out object obj)
        {
            obj = null;
            object tmp = null;

            if (Strong.FirstOrDefault(c => c.Key == id).Value != null)
            {
                tmp = Strong[id];
            }


            if (tmp == null)
            {
                Dictionary <int, object> DicTmp = (Dictionary <int, object>)Weak.Target;
                if (DicTmp == null)
                {
                    return(false);
                }
                object tmp2 = null;
                if (DicTmp.FirstOrDefault(c => c.Key == id).Value != null)
                {
                    tmp2 = DicTmp[id];
                }

                if (tmp2 == null)
                {
                    return(false);
                }
                else
                {
                    obj = tmp2;
                    DicTmp.Remove(id);
                    WeakCount++;
                    return(true);
                }
            }
            else
            {
                Strong.Remove(id);
                obj = tmp;
                StrongCount++;
                return(true);
            }
        }