예제 #1
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
        internal static bool IsSameSort(ResourceList resList1, ResourceList resList2)
        {
            int[] sortProps1 = resList1.SortPropIDs;
            int[] sortProps2 = resList2.SortPropIDs;
            if (sortProps1 == null || sortProps2 == null)
            {
                return(false);
            }

            if (sortProps1.Length != sortProps2.Length)
            {
                return(false);
            }

            for (int i = 0; i < sortProps1.Length; i++)
            {
                if (sortProps1 [i] != sortProps2 [i])
                {
                    return(false);
                }
                if (resList1.SortDirections [i] != resList2.SortDirections [i])
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #2
0
 /// <summary>
 /// Allows to delegate all the comparison operations to a custom resource comparer.
 /// </summary>
 /// <param name="owner">Reserved. This value is ignored when sorting against a custom comparer.</param>
 /// <param name="customComparer">The custom comparer that handles all the comparison operations for this object.
 /// Property IDs are converted to resources before getting into the custom comparer.</param>
 /// <param name="dontReverse"><c>True</c> if you would like to accept the sorting direction of the custom comparer,
 /// and <c>False</c> if you'd like to reverse it.</param>
 public ResourceComparer(IResourceList owner, IResourceComparer customComparer, bool dontReverse)
 {
     _owner               = (ResourceList)owner;
     _sortSettings        = _emptySortSettings;
     _propTypes           = _emptyPropTypes;
     _customComparer      = customComparer;
     _customSortAscending = dontReverse;
 }
예제 #3
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
        /**
         * Merges the data on liveness, virtual properties, sorting from the source list
         * into the destination list.
         */

        private static ResourceList MergeListData(ResourceList dest, ResourceList source)
        {
            if (source.IsLive)
            {
                dest._isLive = true;
            }
            dest.AttachPropertyProviders(source._propertyProviders);
            if (dest.LastComparer == null && source.LastComparer != null)
            {
                dest._lastComparer = source._lastComparer;
            }
            return(dest);
        }
예제 #4
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
        /**
         * Merges the data on liveness, virtual properties, sorting from the two
         * source lists to the dest list.
         */

        private static ResourceList MergeListData(ResourceList dest, ResourceList source1, ResourceList source2)
        {
            dest.AttachPropertyProviders(source1._propertyProviders);
            dest.AttachPropertyProviders(source2._propertyProviders);
            if (IsSameSort(source1, source2) || source2._lastComparer == null)
            {
                dest._lastComparer = source1._lastComparer;
            }
            else if (source1._lastComparer == null)
            {
                dest._lastComparer = source2._lastComparer;
            }
            return(dest);
        }
예제 #5
0
        /// <summary>
        /// Constructs a comparer that uses a hierarchical set of properties to compare by.
        /// </summary>
        /// <param name="owner">A resource list that has a property provider
        /// that will be queried to get the property values for individual resources.</param>
        /// <param name="sortSettings">Deinfes the sorting columns and ascending/descending directions for them.</param>
        /// <param name="propsEquivalent">Specifies whether all the properties are treated equivalent,
        /// which means that if two sorting properties are suggested, the first of them which is defined for that particular object
        /// will take part in the comparison, not necessarily the same props on both objects.</param>
        public ResourceComparer(IResourceList owner, SortSettings sortSettings, bool propsEquivalent)
        {
            if (sortSettings == null)
            {
                throw new ArgumentNullException("sortSettings");
            }
            _owner        = (ResourceList)owner;
            _sortSettings = sortSettings;
            _propTypes    = new PropDataType [_sortSettings.SortProps.Length];

            for (int i = 0; i < _sortSettings.SortProps.Length; i++)
            {
                _propTypes [i] = GetSortPropType(_sortSettings.SortProps [i]);
            }
            _propsEquivalent = propsEquivalent;
        }
예제 #6
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
        public IResourceList Intersect(IResourceList other, bool allowMerge)
        {
            if (other == null)
            {
                return(this);
            }

            ResourceList otherList = (ResourceList)other;

            if (_predicate.Equals(otherList.Predicate))
            {
                Trace.WriteLine("Attempt to intersect lists with equal predicates " + _predicate.ToString());
                return(this);
            }

            if (allowMerge)
            {
                ResourceList          destList  = this;
                ResourceList          srcList   = otherList;
                IntersectionPredicate predicate = null;
                if (_list == null)
                {
                    predicate = _predicate as IntersectionPredicate;
                }
                if (predicate == null && otherList._list == null)
                {
                    srcList   = this;
                    destList  = otherList;
                    predicate = otherList._predicate as IntersectionPredicate;
                }
                if (predicate != null)
                {
                    predicate.AddSource(srcList.Predicate);
                    return(MergeListData(destList, srcList));
                }
            }

            IntersectionPredicate pred = new IntersectionPredicate(_predicate, otherList._predicate);

            ResourceList result = new ResourceList(pred, _isLive || otherList.IsLive);

            return(MergeListData(result, this, otherList));
        }
예제 #7
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
        public IResourceList Minus(IResourceList other)
        {
            if (other == null)
            {
                return(this);
            }

            ResourceList   otherList = (ResourceList)other;
            MinusPredicate pred      = new MinusPredicate(
                _predicate, otherList._predicate);

            ResourceList result = new ResourceList(pred, _isLive || otherList.IsLive);

            result.AttachPropertyProviders(_propertyProviders);
            result.AttachPropertyProviders(otherList._propertyProviders);
            if (_lastComparer != null)
            {
                result._lastComparer = _lastComparer;
            }
            return(result);
        }
예제 #8
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
        public IResourceList Union(IResourceList other, bool allowMerge)
        {
            if (other == null)
            {
                return(this);
            }

            ResourceList otherList = (ResourceList)other;

            if (allowMerge)
            {
                ResourceList   destList  = this;
                ResourceList   srcList   = otherList;
                UnionPredicate predicate = null;
                if (_list == null)
                {
                    predicate = _predicate as UnionPredicate;
                }
                if (predicate == null && otherList._list == null)
                {
                    srcList   = this;
                    destList  = otherList;
                    predicate = otherList._predicate as UnionPredicate;
                }
                if (predicate != null)
                {
                    predicate.AddSource(srcList.Predicate);
                    return(MergeListData(destList, srcList));
                }
            }

            UnionPredicate pred = new UnionPredicate(_predicate, otherList._predicate);

            ResourceList result = new ResourceList(pred, _isLive || otherList.IsLive);

            return(MergeListData(result, this, otherList));
        }
예제 #9
0
 public CachingPredicate(ResourceList cacheList)
 {
     _cacheList = cacheList;
     _cacheList.Sort(new int[] { ResourceProps.Id }, true);
 }
예제 #10
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
 public ValidResourcesEnumerator(ResourceList resourceList)
 {
     _resourceList = resourceList;
     _index        = -1;
 }
예제 #11
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
 public ValidResourcesEnumerable(ResourceList resourceList)
 {
     _resourceList = resourceList;
 }
예제 #12
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
 public ResourceIdCollection(ResourceList baseList)
 {
     _baseList = baseList;
 }