| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | using IceRpc.Features; |
| | | 4 | | using System.Diagnostics.CodeAnalysis; |
| | | 5 | | using ZeroC.Slice; |
| | | 6 | | |
| | | 7 | | namespace IceRpc.Slice.Ice; |
| | | 8 | | |
| | | 9 | | /// <remarks>The IceRpc + Slice integration provides a default implementation for all methods of this interface. |
| | | 10 | | /// </remarks> |
| | | 11 | | [SuppressMessage( |
| | | 12 | | "StyleCop.CSharp.DocumentationRules", |
| | | 13 | | "SA1605:PartialElementDocumentationMustHaveSummary", |
| | | 14 | | Justification = "Use generated summary.")] |
| | | 15 | | public partial interface IIceObjectService |
| | | 16 | | { |
| | | 17 | | /// <summary>Gets the Slice type IDs of all the interfaces implemented by the target service.</summary> |
| | | 18 | | /// <param name="features">The dispatch features.</param> |
| | | 19 | | /// <param name="cancellationToken">A cancellation token that receives the cancellation requests.</param> |
| | | 20 | | /// <returns>The Slice type IDs of all these interfaces, sorted alphabetically.</returns> |
| | | 21 | | public ValueTask<IEnumerable<string>> IceIdsAsync(IFeatureCollection features, CancellationToken cancellationToken) |
| | 2 | 22 | | { |
| | 2 | 23 | | var sortedSet = new SortedSet<string>(StringComparer.Ordinal); |
| | 18 | 24 | | foreach (Type type in GetType().GetInterfaces()) |
| | 6 | 25 | | { |
| | 6 | 26 | | if (type.GetSliceTypeId() is string typeId) |
| | 4 | 27 | | { |
| | 4 | 28 | | sortedSet.Add(typeId); |
| | 4 | 29 | | } |
| | 6 | 30 | | } |
| | 2 | 31 | | return new(sortedSet); |
| | 2 | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary>Tests whether the target service implements the specified interface.</summary> |
| | | 35 | | /// <param name="id">The Slice type ID of the interface to test against.</param> |
| | | 36 | | /// <param name="features">The dispatch features.</param> |
| | | 37 | | /// <param name="cancellationToken">A cancellation token that receives the cancellation requests.</param> |
| | | 38 | | /// <returns>True when the target service implements this interface; otherwise, false.</returns> |
| | | 39 | | public ValueTask<bool> IceIsAAsync( |
| | | 40 | | string id, |
| | | 41 | | IFeatureCollection features, |
| | | 42 | | CancellationToken cancellationToken) |
| | 8 | 43 | | { |
| | 57 | 44 | | foreach (Type type in GetType().GetInterfaces()) |
| | 19 | 45 | | { |
| | 19 | 46 | | if (type.GetSliceTypeId() is string typeId && typeId == id) |
| | 5 | 47 | | { |
| | 5 | 48 | | return new(true); |
| | | 49 | | } |
| | 14 | 50 | | } |
| | 3 | 51 | | return new(false); |
| | 8 | 52 | | } |
| | | 53 | | |
| | | 54 | | /// <summary>Pings the service.</summary> |
| | | 55 | | /// <param name="features">The dispatch features.</param> |
| | | 56 | | /// <param name="cancellationToken">A cancellation token that receives the cancellation requests.</param> |
| | | 57 | | /// <returns>A value task that completes when this implementation completes.</returns> |
| | 2 | 58 | | public ValueTask IcePingAsync(IFeatureCollection features, CancellationToken cancellationToken) => default; |
| | | 59 | | } |