From b888c85937e0414a87b9693be4fcc98b0d35bc1a Mon Sep 17 00:00:00 2001 From: TekH Date: Sun, 7 Jun 2026 11:07:49 +0200 Subject: [PATCH] Add SignatureDtoExtensions with Convert method Introduce a new static class `SignatureDtoExtensions` that adds a `Convert` extension method for collections of `SignatureDto` objects. This method converts all `SignatureDto` instances in a collection to a specified `UnitOfLength`, modifying them in place and returning the same collection. The method includes: - A generic constraint to support any `IEnumerable`. - Null checks to ensure the collection is not null. - Comprehensive XML documentation with usage examples and notes. --- .../Models/SignatureDto.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/EnvelopeGenerator.ReceiverUI/Models/SignatureDto.cs b/EnvelopeGenerator.ReceiverUI/Models/SignatureDto.cs index 07790b5c..c54ff873 100644 --- a/EnvelopeGenerator.ReceiverUI/Models/SignatureDto.cs +++ b/EnvelopeGenerator.ReceiverUI/Models/SignatureDto.cs @@ -65,4 +65,37 @@ public class SignatureDto }; } } +} + +public static class SignatureDtoExtensions +{ + /// + /// Converts all signatures in the collection to the specified unit of length. + /// + /// Type of the collection (IEnumerable, List, etc.) + /// Collection of SignatureDto objects to convert. + /// Target unit of measurement (Inch or Point). + /// The same collection with all signatures converted to the specified unit. + /// Thrown when signatures collection is null. + /// + /// Usage: + /// + /// var signatures = await SignatureService.GetAsync(envelopeKey); + /// var convertedSignatures = signatures.ConvertAll(UnitOfLength.Point); + /// + /// Note: This method modifies each SignatureDto object in place and returns the same collection. + /// + public static T Convert(this T signatures, UnitOfLength unitOfLength) + where T : IEnumerable + { + if (signatures == null) + throw new ArgumentNullException(nameof(signatures)); + + foreach (var signature in signatures) + { + signature.Convert(unitOfLength); + } + + return signatures; + } } \ No newline at end of file