Пример #1
0
        public static void DisposeAndClearCollection <T>(this ICollection <T> listInterface)
        {
            if (listInterface != null)
            {
                foreach (object o in listInterface)
                {
                    DisposeHelper.DisposeItem(o);
                }

                listInterface.Clear();
            }
        }
        public static void Dispose <TKey, TValue>(this IDictionary <TKey, TValue> dictionaryInterface)
        {
            if (dictionaryInterface != null)
            {
                ICollection <TValue> values = dictionaryInterface.Values;

                foreach (object o in values)
                {
                    DisposeHelper.DisposeItem(o);
                }
            }
        }
Пример #3
0
 public static void Dispose(this IList listInterface)
 {
     if (listInterface != null)
     {
         //for (int i = listInterface.Count - 1; i >= 0; i--)
         //foreach (object o in listInterface)
         for (int i = 0; i < listInterface.Count; i++)
         {
             object o = listInterface[i];
             DisposeHelper.DisposeItem(o);
         }
     }
 }
Пример #4
0
        public static void DisposeAndClear(this IList listInterface)
        {
            if (listInterface != null)
            {
                lock (listInterface)
                {
                    //for (int i = listInterface.Count - 1; i >= 0; i--)
                    foreach (object o in listInterface)
                    {
                        DisposeHelper.DisposeItem(o);
                    }

                    listInterface.Clear();
                }
            }
        }
        public static void DisposeAndClear <TKey, TValue>(this IDictionary <TKey, TValue> dictionaryInterface)
        {
            if (dictionaryInterface != null)
            {
                ICollection <TValue> values = dictionaryInterface.Values;

                /*Dictionary<int, ConditionalAccessContext>.Enumerator en = _mapSubChannels.GetEnumerator();
                 * while (en.MoveNext())
                 * {
                 *
                 * }*/

                foreach (object o in values)
                {
                    IDisposable disposable = o as IDisposable;
                    DisposeHelper.DisposeItem(o);
                }
                dictionaryInterface.Clear();
            }
        }