/// <summary> /// Opens the component. /// </summary> /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param> /// <returns></returns> public async virtual Task OpenAsync(string correlationId) { if (IsOpen()) { return; } if (_endpoint == null) { _endpoint = CreateLocalEndpoint(); _endpoint.Register(this); _localEndpoint = true; } if (_localEndpoint) { await _endpoint.OpenAsync(correlationId).ContinueWith(task => { _opened = task.Exception == null; }); } else { _opened = true; } }
/// <summary> /// Sets references to dependent components. /// </summary> /// <param name="references">references to locate the component dependencies.</param> public virtual void SetReferences(IReferences references) { _references = references; _logger.SetReferences(references); _counters.SetReferences(references); _dependencyResolver.SetReferences(references); // Get endpoint _endpoint = _dependencyResolver.GetOneOptional("endpoint") as HttpEndpoint; _localEndpoint = _endpoint == null; // Or create a local one if (_endpoint == null) { _endpoint = CreateLocalEndpoint(); } // Add registration callback to the endpoint _endpoint.Register(this); }