| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | using IceRpc.Locator; |
| | | 4 | | using IceRpc.Slice.Ice; |
| | | 5 | | using Microsoft.Extensions.Logging; |
| | | 6 | | using Microsoft.Extensions.Logging.Abstractions; |
| | | 7 | | |
| | | 8 | | namespace IceRpc; |
| | | 9 | | |
| | | 10 | | /// <summary>Provides extension methods for <see cref="Pipeline" /> to add the locator interceptor.</summary> |
| | | 11 | | public static class LocatorPipelineExtensions |
| | | 12 | | { |
| | | 13 | | /// <summary>Adds a <see cref="LocatorInterceptor" /> to the pipeline, using the specified locator.</summary> |
| | | 14 | | /// <param name="pipeline">The pipeline being configured.</param> |
| | | 15 | | /// <param name="locator">The locator used for the resolutions.</param> |
| | | 16 | | /// <returns>The pipeline being configured.</returns> |
| | | 17 | | public static Pipeline UseLocator(this Pipeline pipeline, ILocator locator) => |
| | 0 | 18 | | UseLocator(pipeline, locator, NullLoggerFactory.Instance); |
| | | 19 | | |
| | | 20 | | /// <summary>Adds a <see cref="LocatorInterceptor" /> to the pipeline, using the specified locator.</summary> |
| | | 21 | | /// <param name="pipeline">The pipeline being configured.</param> |
| | | 22 | | /// <param name="locator">The locator used for the resolutions.</param> |
| | | 23 | | /// <param name="loggerFactory">The logger factory used to create a <see cref="ILogger{TCategoryName}" /> for |
| | | 24 | | /// <see cref="LocatorInterceptor" />.</param> |
| | | 25 | | /// <returns>The pipeline being configured.</returns> |
| | | 26 | | public static Pipeline UseLocator(this Pipeline pipeline, ILocator locator, ILoggerFactory loggerFactory) => |
| | 0 | 27 | | UseLocator( |
| | 0 | 28 | | pipeline, |
| | 0 | 29 | | new LocatorLocationResolver( |
| | 0 | 30 | | locator, |
| | 0 | 31 | | new LocatorOptions(), |
| | 0 | 32 | | loggerFactory.CreateLogger<LocatorInterceptor>())); |
| | | 33 | | |
| | | 34 | | /// <summary>Adds a <see cref="LocatorInterceptor" /> to the pipeline, using the specified location resolver. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <param name="pipeline">The pipeline being configured.</param> |
| | | 37 | | /// <param name="locationResolver">The location resolver instance.</param> |
| | | 38 | | /// <returns>The pipeline being configured.</returns> |
| | | 39 | | public static Pipeline UseLocator(this Pipeline pipeline, ILocationResolver locationResolver) => |
| | 0 | 40 | | pipeline.Use(next => new LocatorInterceptor(next, locationResolver)); |
| | | 41 | | } |