public void Register() { try { foreach (IApiIpcService apiIpcService in apiServices) { Type interfaceType = GetInterfaceType(apiIpcService); string serverName = GetCurrentInstanceServerName(modelMetadataService.ModelFilePath); apiIpcServer?.Dispose(); apiIpcServer = new ApiIpcServer(serverName); if (!apiIpcServer.TryPublishService(interfaceType, apiIpcService)) { throw new ApplicationException($"Failed to register rpc instance {serverName}"); } Log.Info($"Registered: {serverName}"); } } catch (Exception e) { Log.Exception(e); throw; } }
public void Test2() { TestApiService instanceService = new TestApiService(); string serverName = Guid.NewGuid().ToString(); using (ApiIpcServer apiIpcServer = new ApiIpcServer(serverName)) using (ApiIpcClient apiIpcClient = new ApiIpcClient(serverName)) { if (apiIpcServer.TryPublishService <ITestApiService>(instanceService)) { if (ApiIpcClient.IsServerRegistered(serverName)) { // Another instance for that working folder is already running, activate that. ITestApiService service = apiIpcClient.Service <ITestApiService>(); string doubleName = service.GetDoubleName("hej"); Assert.AreEqual("hejhej", doubleName); return; } } } Assert.Fail("Error"); }
private async Task RegisterAsync(string solutionFilePath) { try { string serverName = GetServerName(solutionFilePath); Log.Debug($"Register: {serverName}"); apiIpcServer?.Dispose(); apiIpcServer = new ApiIpcServer(serverName); await apiIpcServer.PublishServiceAsync <IVsExtensionApi>(vsExtensionApiService); Log.Debug($"Registered: {serverName}"); } catch (Exception e) { Log.Error($"Error {e}"); throw; } }
private void HandleCloseSolution(object sender, EventArgs e) { Log.Warn("Close solution"); apiIpcServer?.Dispose(); apiIpcServer = null; }