internal override IntArrayList GetMatchingResources(out bool sortedById) { sortedById = false; IntArrayList result = null; for (int i = 0; i < _resTypeIds.Length; i++) { ResourceListPredicate basePredicate = new ResourceTypePredicate(_resTypeIds [i]); ResourceListPredicate cachedPredicate = MyPalStorage.Storage.GetCachedPredicate(basePredicate); bool tempSortedById = false; object syncObject = null; IntArrayList tempResult; if (cachedPredicate != null) { tempResult = cachedPredicate.GetSortedMatchingResourcesRef(out syncObject); } else { tempResult = basePredicate.GetMatchingResources(out tempSortedById); syncObject = null; } if (result == null) { if (syncObject == null) { result = tempResult; } else { lock ( syncObject ) { result = (IntArrayList)tempResult.Clone(); } } } else { if (syncObject == null) { result.AddRange(tempResult); } else { lock ( syncObject ) { result.AddRange(tempResult); } } } } if (result == null) { result = new IntArrayList(); } return(result); }
internal override IntArrayList GetMatchingResources( out bool sortedById ) { bool lhsSortedById = false; IntArrayList result = _lhs.GetMatchingResources( out lhsSortedById ); if ( _rhs.GetSelectionCost() >= 3 ) { for( int i=result.Count-1; i >= 0; i-- ) { IResource resource; try { resource = MyPalStorage.Storage.LoadResource( result [i], true, _lhs.GetKnownType() ); } catch( InvalidResourceIdException ) { result.RemoveAt( i ); continue; } if ( resource.IsDeleted || _rhs.MatchResource( resource, null ) != PredicateMatch.None ) { result.RemoveAt( i ); } } } else { if ( !lhsSortedById ) { result.Sort(); lhsSortedById = true; } object rhsSyncObject; IntArrayList minus = _rhs.GetSortedMatchingResourcesRef( out rhsSyncObject ); if ( rhsSyncObject == null ) { result.MinusSorted( minus ); } else { lock( rhsSyncObject ) { result.MinusSorted( minus ); } } } sortedById = lhsSortedById; return result; }