diff --git a/src/UiPath.CoreIpc.BackCompat/ServiceHostBuilder.cs b/src/UiPath.CoreIpc.BackCompat/ServiceHostBuilder.cs index 8172a163..7cc10624 100644 --- a/src/UiPath.CoreIpc.BackCompat/ServiceHostBuilder.cs +++ b/src/UiPath.CoreIpc.BackCompat/ServiceHostBuilder.cs @@ -20,7 +20,7 @@ public ServiceHostBuilder(IServiceProvider serviceProvider) public ServiceHostBuilder AddEndpoint(EndpointSettings settings) { settings = settings.WithServiceProvider(_serviceProvider); - Endpoints.Add(settings.Name, settings); + Endpoints.Add(settings.ContractType.Name, settings); return this; } diff --git a/src/UiPath.CoreIpc/Extensibility/ClientBase.cs b/src/UiPath.CoreIpc/Extensibility/ClientBase.cs index 6cf7a54a..0772a32f 100644 --- a/src/UiPath.CoreIpc/Extensibility/ClientBase.cs +++ b/src/UiPath.CoreIpc/Extensibility/ClientBase.cs @@ -21,7 +21,7 @@ public TProxy GetProxy() where TProxy : class internal void ValidateInternal() { - var haveDeferredInjectedCallbacks = Callbacks?.Any(x => !x.Service.HasServiceProvider() && x.Service.MaybeGetInstance() is null) ?? false; + var haveDeferredInjectedCallbacks = Callbacks?.Any(x => x.Service.MaybeGetServiceProvider() is null && x.Service.MaybeGetInstance() is null) ?? false; if (haveDeferredInjectedCallbacks && ServiceProvider is null) { diff --git a/src/UiPath.CoreIpc/Helpers/Router.cs b/src/UiPath.CoreIpc/Helpers/Router.cs index 75f2be51..0683b7e4 100644 --- a/src/UiPath.CoreIpc/Helpers/Router.cs +++ b/src/UiPath.CoreIpc/Helpers/Router.cs @@ -40,13 +40,13 @@ internal abstract record ServiceFactory public virtual ServiceFactory WithProvider(IServiceProvider? serviceProvider) => this; internal virtual object? MaybeGetInstance() => null; - internal virtual bool HasServiceProvider() => false; + internal virtual IServiceProvider? MaybeGetServiceProvider() => null; public sealed record Injected : ServiceFactory { public required IServiceProvider ServiceProvider { get; init; } - internal override bool HasServiceProvider() => ServiceProvider is not null; + internal override IServiceProvider? MaybeGetServiceProvider() => ServiceProvider; public override IDisposable? Get(out object service) { diff --git a/src/UiPath.CoreIpc/Server/ServiceHostBuilder.cs b/src/UiPath.CoreIpc/Server/ServiceHostBuilder.cs index f34dd63a..4914535a 100644 --- a/src/UiPath.CoreIpc/Server/ServiceHostBuilder.cs +++ b/src/UiPath.CoreIpc/Server/ServiceHostBuilder.cs @@ -4,12 +4,13 @@ public record EndpointSettings { - internal TaskScheduler? Scheduler { get; set; } + public TaskScheduler? Scheduler { get; set; } public BeforeCallHandler? BeforeCall { get; set; } + public Type ContractType => Service.Type; + public object? ServiceInstance => Service.MaybeGetInstance(); + public IServiceProvider? ServiceProvider => Service.MaybeGetServiceProvider(); internal ServiceFactory Service { get; } - internal string Name => Service.Type.Name; - public EndpointSettings(Type contractType, object? serviceInstance) : this( serviceInstance is not null ? new ServiceFactory.Instance() @@ -42,7 +43,7 @@ public void Validate() } } - protected internal virtual EndpointSettings WithServiceProvider(IServiceProvider serviceProvider) + public virtual EndpointSettings WithServiceProvider(IServiceProvider serviceProvider) => new EndpointSettings(Service.Type, serviceProvider) { BeforeCall = BeforeCall, @@ -50,12 +51,12 @@ protected internal virtual EndpointSettings WithServiceProvider(IServiceProvider }; } -public record EndpointSettings : EndpointSettings where TContract : class +public sealed record EndpointSettings : EndpointSettings where TContract : class { public EndpointSettings(TContract? serviceInstance = null) : base(typeof(TContract), serviceInstance) { } public EndpointSettings(IServiceProvider serviceProvider) : base(typeof(TContract), serviceProvider) { } - protected internal override EndpointSettings WithServiceProvider(IServiceProvider serviceProvider) + public override EndpointSettings WithServiceProvider(IServiceProvider serviceProvider) => new EndpointSettings(serviceProvider) { BeforeCall = BeforeCall,