public static T[][] SplitArray <T> ( [NotNull] T[] array, int partCount ) { Sure.NotNull(array, nameof(array)); Sure.Positive(partCount, nameof(partCount)); List <T[]> result = new List <T[]>(partCount); int length = array.Length; int chunkSize = length / partCount; while (chunkSize * partCount < length) { chunkSize++; } int offset = 0; for (int i = 0; i < partCount; i++) { int size = Math.Min(chunkSize, length - offset); T[] chunk = new T[size]; Array.Copy(array, offset, chunk, 0, size); result.Add(chunk); offset += size; } return(result.ToArray()); }
/// <summary> /// Construction. /// </summary> public RetryManager ( int retryLimit ) { Sure.Positive(retryLimit, "retryLimit"); RetryLimit = retryLimit; }
/// <summary> /// Constructor. /// </summary> public RetryManager ( int retryLimit, [CanBeNull] Func <Exception, bool> resolver ) { Sure.Positive(retryLimit, "retryLimit"); RetryLimit = retryLimit; _resolver = resolver; }