using Connected.Net; using Connected.Net.Server; using Connected.ServiceModel; namespace Connected.Services; public abstract class DistributedService : Service { public DistributedService(IContext context) : base(context) { if (context is null) throw new ArgumentNullException(null, nameof(context)); EndpointServer = context.GetService(); if (EndpointServer is null) throw new NullReferenceException(nameof(IEndpointServer)); Http = context.GetService(); if (Http is null) throw new NullReferenceException(nameof(IHttpService)); } private IEndpointServer EndpointServer { get; } protected async Task ParseUrl(string relativePath) { if (await IsServer()) throw new InvalidOperationException(SR.ErrNoServer); return $"{EndpointServer.ServerUrl}/{relativePath.Trim('/')}"; } protected IHttpService Http { get; } protected async Task IsServer() { return await EndpointServer.IsServer(); } }