-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPolylineEncoderExtensions.cs
More file actions
48 lines (43 loc) · 1.94 KB
/
PolylineEncoderExtensions.cs
File metadata and controls
48 lines (43 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Copyright © Pete Sramek. All rights reserved.
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace PolylineAlgorithm.Extensions;
using PolylineAlgorithm.Abstraction;
using PolylineAlgorithm.Internal.Diagnostics;
using System;
/// <summary>
/// Provides extension methods for the <see cref="IPolylineEncoder{TValue, TPolyline}"/> interface to facilitate encoding values into polylines.
/// </summary>
public static class PolylineEncoderExtensions {
/// <summary>
/// Encodes an array of <typeparamref name="TValue"/> instances into an encoded polyline.
/// </summary>
/// <typeparam name="TValue">The type that represents a value to encode.</typeparam>
/// <typeparam name="TPolyline">The type that represents the encoded polyline output.</typeparam>
/// <param name="encoder">
/// The <see cref="IPolylineEncoder{TValue, TPolyline}"/> instance used to perform the encoding operation.
/// </param>
/// <param name="values">
/// The array of <typeparamref name="TValue"/> objects to encode.
/// </param>
/// <returns>
/// A <typeparamref name="TPolyline"/> instance representing the encoded polyline for the provided values.
/// </returns>
/// <exception cref="ArgumentNullException">
/// Thrown when <paramref name="encoder"/> or <paramref name="values"/> is <see langword="null"/>.
/// </exception>
public static TPolyline Encode<TValue, TPolyline>(
this IPolylineEncoder<TValue, TPolyline> encoder,
TValue[] values,
PolylineEncodingOptions<TValue>? options = null,
CancellationToken cancellationToken = default) {
if (encoder is null) {
ExceptionGuard.ThrowArgumentNull(nameof(encoder));
}
if (values is null) {
ExceptionGuard.ThrowArgumentNull(nameof(values));
}
return encoder.Encode(values.AsSpan(), options, cancellationToken);
}
}