Example #1
0
        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());
        }
Example #2
0
        /// <summary>
        /// Construction.
        /// </summary>
        public RetryManager
        (
            int retryLimit
        )
        {
            Sure.Positive(retryLimit, "retryLimit");

            RetryLimit = retryLimit;
        }
Example #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public RetryManager
        (
            int retryLimit,
            [CanBeNull] Func <Exception, bool> resolver
        )
        {
            Sure.Positive(retryLimit, "retryLimit");

            RetryLimit = retryLimit;
            _resolver  = resolver;
        }