Esempio n. 1
0
        public static void DisposeAndClearList(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);
                }

                listInterface.Clear();
            }
        }
Esempio n. 2
0
        public static void DisposeAndClearCollection <T>(this ICollection <T> listInterface)
        {
            if (listInterface != null)
            {
                lock (listInterface)
                {
                    foreach (object o in listInterface)
                    {
                        DisposeHelper.DisposeItem(o);
                    }

                    listInterface.Clear();
                }
            }
        }
Esempio n. 3
0
 public static void Dispose(this IList listInterface)
 {
     if (listInterface != null)
     {
         lock (listInterface)
         {
             //for (int i = listInterface.Count - 1; i >= 0; i--)
             //foreach (object o in listInterface)
             foreach (object o in listInterface)
             {
                 DisposeHelper.DisposeItem(o);
             }
         }
     }
 }
        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();
            }
        }