예제 #1
0
        public override bool Equals(object obj)
        {
            if (Object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            PlainListPredicate rhs = obj as PlainListPredicate;

            if (rhs == null)
            {
                return(false);
            }

            if (_resources.Count != rhs._resources.Count)
            {
                return(false);
            }

            for (int i = 0; i < _resources.Count; i++)
            {
                if (rhs._resources.IndexOf(_resources [i]) < 0)
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        private ResourceListPredicate OptimizePlainLists()
        {
            ArrayList predicates = ArrayListPool.Alloc();

            try
            {
                PlainListPredicate plainList = new PlainListPredicate(new IntArrayList());
                for (int i = 0; i < _sourcePredicates.Length; i++)
                {
                    PlainListPredicate sourcePlainList = _sourcePredicates [i] as PlainListPredicate;
                    if (sourcePlainList != null)
                    {
                        if (sourcePlainList.Count > 0)
                        {
                            bool sortedById;
                            plainList.AddRange(sourcePlainList.GetMatchingResources(out sortedById));
                        }
                    }
                    else
                    {
                        predicates.Add(_sourcePredicates [i]);
                    }
                }

                if (predicates.Count == 0)
                {
                    return(plainList);
                }

                if (plainList.Count > 0)
                {
                    predicates.Add(plainList);
                }

                if (predicates.Count == 1)
                {
                    return((ResourceListPredicate)predicates [0]);
                }

                _sourcePredicates = (ResourceListPredicate[])predicates.ToArray(typeof(ResourceListPredicate));
            }
            finally
            {
                ArrayListPool.Dispose(predicates);
            }
            return(this);
        }
예제 #3
0
        internal override ResourceListPredicate Optimize(bool isLive)
        {
            ResourceListPredicate result = this;

            if (isLive)
            {
                int plainListCount = 0;
                for (int i = 0; i < _sourcePredicates.Length; i++)
                {
                    PlainListPredicate plainList = _sourcePredicates [i] as PlainListPredicate;
                    if (plainList != null)
                    {
                        plainListCount++;
                        if (plainListCount > 1 || plainList.Count == 0)
                        {
                            result = OptimizePlainLists();
                        }
                    }
                }
            }

            return(OptimizeSourcePredicates(result, isLive));
        }