protected override bool Process(IInteraction parameters) { CacheInteraction cache; if (UseConfigListname) { cache = new CacheInteraction(this.ListName, parameters); } else { cache = new CacheInteraction(parameters); } if (cache.RequiresFill) { unavailable.TryProcess(cache); } if (DontPartition) { return(IterateWithoutPartition(parameters, cache)); } else { return(IterateWithPartition(parameters, cache)); } }
/// <summary> /// Iterates with partitioning /// </summary> /// <returns><c>true</c>, if successful, <c>false</c> otherwise.</returns> /// <param name="parameters">Parameters.</param> /// <param name="cache">Cache.</param> bool IterateWithPartition(IInteraction parameters, CacheInteraction cache) { bool success = true; object pageObj; int page; if (parameters.TryGetFallback(this.pageVariable, out pageObj)) { page = (int)pageObj; } else { throw new CacheException("pagenumber missing"); } if (RelativePartition) { int pageSize = (int)Math.Ceiling((float)cache.List.Count / (float)Partition); for (int i = pageSize * page; i < (pageSize * (page + 1)); i++) { success &= ListPick(cache.List, i, parameters); } } else { for (int i = this.Partition * page; i < (this.Partition * (page + 1)); i++) { success &= ListPick(cache.List, i, parameters); } } return(success); }
/// <summary> /// Iterates without partitioning. /// </summary> /// <returns><c>true</c>, if successful, <c>false</c> otherwise.</returns> /// <param name="parameters">Parameters.</param> /// <param name="cache">Cache.</param> bool IterateWithoutPartition(IInteraction parameters, CacheInteraction cache) { bool success = true; foreach (IInteraction item in cache.List) { success &= iterator.TryProcess(item.Clone(parameters)); } return(success); }