// TODO: Put strings into the resources. // public static ArrayPartitionBoundary Get(int arrayLength, ArgumentUtilitiesHandle <int?> offset, ArgumentUtilitiesHandle <int?> count) { arrayLength .Arg(nameof(arrayLength)) .EnsureNotLessThan(0); var locOffset = offset .EnsureNotLessThan(0) .EnsureNotGreaterThan( operand: arrayLength - 1, exceptionMessageFirstLineFactory: locHnd => $"Указанное смещение не соответствует длине массива (или к.л. другой последовательности).{Environment.NewLine}\tДлина массива:{Environment.NewLine}{arrayLength.ToString("d").FmtStr().GNLI2()}{Environment.NewLine}\tУказанное смещение:{Environment.NewLine}{locHnd.Value.Value.ToString("d").FmtStr().GNLI2()}") .Value ?? 0; var maxCount = arrayLength - locOffset; var locCount = count .EnsureNotLessThan(0) .EnsureNotGreaterThan( operand: maxCount, exceptionMessageFirstLineFactory: locHnd => $"Указанная длина сегмента массива не соответствует указанному смещению и всей длине массива (или к.л. другой последовательности).{Environment.NewLine}\tДлина массива:{Environment.NewLine}{arrayLength.ToString("d").FmtStr().GNLI2()}{Environment.NewLine}\tУказанное смещение:{Environment.NewLine}{locOffset.ToString("d").FmtStr().GNLI2()}") .Value ?? maxCount; // return (new ArrayPartitionBoundary( offset: locOffset, count: locCount)); }
public ArrayPartitionBoundary(ArgumentUtilitiesHandle <int> offset, ArgumentUtilitiesHandle <int> count) { offset.EnsureNotLessThan(0); count.EnsureNotLessThan(0); // Offset = offset.Value; Count = count.Value; }