Exemplo n.º 1
0
        /// <summary>
        /// Copies both the structure and data for this Collection.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <returns></returns>
        public static CustomList <T> Copy <T>(this CustomList <T> list)
        {
            CustomList <T> returnList = new CustomList <T>();

            returnList.PreserveVid = true;
            IEnumerable <BaseItem> items = list.Cast <BaseItem>();

            foreach (BaseItem item in items)
            {
                returnList.Add((T)item.Copy());
            }
            return(returnList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Commits all the changes made to this Collection since the last time ItemList.AcceptChanges()
        /// was called.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        public static void AcceptChanges <T>(this CustomList <T> list)
        {
            BaseItem[] items = list.Cast <BaseItem>().ToArray();
            foreach (BaseItem item in items)
            {
                switch (item.State)
                {
                case ItemState.Deleted:
                    list.Remove((T)Convert.ChangeType(item, typeof(T)));
                    break;

                case ItemState.Modified:
                case ItemState.Added:
                    item.SetUnchanged();
                    break;
                }
            }
        }