| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="Address.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Linq; |
| | | 8 | | |
| | | 9 | | namespace MyNet.Geography; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Represents a physical address, including optional geographic coordinates. This record can be used to store and manip |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="Street">The street address.</param> |
| | | 15 | | /// <param name="PostalCode">The postal code.</param> |
| | | 16 | | /// <param name="City">The city.</param> |
| | | 17 | | /// <param name="Country">The country.</param> |
| | | 18 | | /// <param name="Coordinates">The geographic coordinates.</param> |
| | | 19 | | public record Address(string? Street = null, string? PostalCode = null, string? City = null, Country? Country = null, Co |
| | | 20 | | { |
| | | 21 | | /// <summary> |
| | | 22 | | /// Returns a string that represents the address, formatted as a space-separated list of the street, postal code, |
| | | 23 | | /// city, and country name. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <remarks>This method concatenates the address components, ensuring that only non-empty values are |
| | | 26 | | /// included in the final output. The country name is accessed through the Country property, which may be |
| | | 27 | | /// null.</remarks> |
| | | 28 | | /// <returns>A string containing the formatted address. If any of the address components are null or empty, they are |
| | | 29 | | /// from the result.</returns> |
| | 12 | 30 | | public override string ToString() => string.Join(" ", new[] { Street, PostalCode, City, Country?.Name }.Where(x => ! |
| | | 31 | | } |
| | | 32 | | |