public static ICollectionView GetDefaultView(object source)
        {
            ICollectionView result = null;

            if (source != null && !defaultViews.TryGetValue(source, out result))
            {
                IList list = source as IList;
                IEnumerable enumerable = source as IEnumerable;

                if (list != null)
                {
                    result = new ListCollectionView(list);
                }
                else if (enumerable != null)
                {
                    result = new EnumerableCollectionView(enumerable);
                }

                if (result != null)
                {
                    defaultViews.Add(source, result);
                }
            }

            return result;
        }
Exemple #2
0
        public static ICollectionView GetDefaultView(object source)
        {
            ICollectionView result = null;

            if (source != null && !defaultViews.TryGetValue(source, out result))
            {
                IList       list       = source as IList;
                IEnumerable enumerable = source as IEnumerable;

                if (list != null)
                {
                    result = new ListCollectionView(list);
                }
                else if (enumerable != null)
                {
                    result = new EnumerableCollectionView(enumerable);
                }

                if (result != null)
                {
                    defaultViews.Add(source, result);
                }
            }

            return(result);
        }