public DebugConnection(IAddressConversion <IPEndPoint> addressConversion, IMetadataAccessor metadataAccessor, IOptions <ModuleDebugOptions> optionsAccessor, IOptions <RemoteMessagingOptions> remoteOptionsAccessor, IServiceProvider serviceProvider, ILoggerFactory loggerFactory = null) { if (addressConversion == null) { throw new ArgumentNullException(nameof(addressConversion)); } if (metadataAccessor == null) { throw new ArgumentNullException(nameof(metadataAccessor)); } if (optionsAccessor == null) { throw new ArgumentNullException(nameof(optionsAccessor)); } if (remoteOptionsAccessor == null) { throw new ArgumentNullException(nameof(remoteOptionsAccessor)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } _addressConversion = addressConversion; _metadataAccessor = metadataAccessor; _options = optionsAccessor.Value ?? new ModuleDebugOptions(); _remoteOptions = remoteOptionsAccessor.Value ?? new RemoteMessagingOptions(); _serviceProvider = serviceProvider; _loggerFactory = loggerFactory; _logger = _loggerFactory?.CreateLogger <DebugConnection>(); _debugPort = new Lazy <IPEndPoint>(() => _addressConversion.Parse(_options.DebugConnection), LazyThreadSafetyMode.PublicationOnly); _tcpClientLazy = new DisposableAsyncLazy <TcpClient>( factory: CreateTcpClientAsync, disposal: tcpClient => { tcpClient.Dispose(); return(Task.CompletedTask); }, options: DisposableAsyncLazyOptions.Autostart | DisposableAsyncLazyOptions.ExecuteOnCallingThread); _proxyHostLazy = new DisposableAsyncLazy <ProxyHost>( factory: CreateProxyHostAsync, disposal: proxyHost => proxyHost.DisposeAsync(), options: DisposableAsyncLazyOptions.Autostart | DisposableAsyncLazyOptions.ExecuteOnCallingThread); }
public DebugPort(IServiceProvider serviceProvider, IAddressConversion <IPEndPoint> addressConversion, IOptions <ModularityOptions> optionsAccessor, IRemoteMessageDispatcher messageDispatcher, ILoggerFactory loggerFactory = null) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (addressConversion == null) { throw new ArgumentNullException(nameof(addressConversion)); } if (optionsAccessor == null) { throw new ArgumentNullException(nameof(optionsAccessor)); } if (messageDispatcher == null) { throw new ArgumentNullException(nameof(messageDispatcher)); } var options = optionsAccessor.Value ?? new ModularityOptions(); _serviceProvider = serviceProvider; _messageDispatcher = messageDispatcher; _loggerFactory = loggerFactory; _logger = _loggerFactory?.CreateLogger <DebugPort>(); var endPoint = addressConversion.Parse(options.DebugConnection); _tcpHost = new TcpListener(endPoint); _connectionProcess = new AsyncProcess(ConnectProcedure); _initializationHelper = new AsyncInitializationHelper <IPEndPoint>(InitializeInternalAsync); _disposeHelper = new AsyncDisposeHelper(DisposeInternalAsync); }