| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | using IceRpc.Internal; |
| | | 4 | | |
| | | 5 | | namespace IceRpc.Ice; |
| | | 6 | | |
| | | 7 | | public partial record struct Identity |
| | | 8 | | { |
| | | 9 | | /// <summary>Gets the null identity.</summary> |
| | 10 | 10 | | internal static Identity Empty { get; } = new("", ""); |
| | | 11 | | |
| | | 12 | | /// <summary>Parses a path into an identity, including the null/empty identity.</summary> |
| | | 13 | | /// <param name="path">The path (percent escaped).</param> |
| | | 14 | | /// <returns>The corresponding identity.</returns> |
| | | 15 | | public static Identity Parse(string path) |
| | 66 | 16 | | { |
| | 66 | 17 | | var iceIdentity = IceIdentity.Parse(path); |
| | 63 | 18 | | return new(iceIdentity.Name, iceIdentity.Category); |
| | 63 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary>Converts this identity into a path.</summary> |
| | | 22 | | /// <returns>The identity converted into a path string.</returns> |
| | 60 | 23 | | public readonly string ToPath() => new IceIdentity(Name, Category).ToPath(); |
| | | 24 | | |
| | | 25 | | /// <summary>Converts this identity into a path string.</summary> |
| | | 26 | | /// <returns>The identity converted into a path string.</returns> |
| | 0 | 27 | | public override readonly string ToString() => ToPath(); |
| | | 28 | | } |