/// <summary> /// Initializes a new instance of the <see cref="RoutableDocumentFilter"/> class. /// </summary> public RoutableDocumentFilter(IOptions <GlobalSettings> globalSettings, IOptions <WebRoutingSettings> routingSettings, IHostingEnvironment hostingEnvironment, EndpointDataSource endpointDataSource) { _globalSettings = globalSettings.Value; _routingSettings = routingSettings.Value; _hostingEnvironment = hostingEnvironment; _endpointDataSource = endpointDataSource; _endpointDataSource.GetChangeToken().RegisterChangeCallback(EndpointsChanged, null); }
private void EndpointsChanged(object value) { lock (_routeLocker) { // try clearing each entry foreach (var r in _routeChecks.Keys.ToList()) { _routeChecks.TryRemove(r, out _); } // re-register after it has changed so we keep listening _endpointDataSource.GetChangeToken().RegisterChangeCallback(EndpointsChanged, null); } }
private T Initialize() { lock (_lock) { var changeToken = _dataSource.GetChangeToken(); _value = _initializeCore(_dataSource.Endpoints); // Don't resubscribe if we're already disposed. if (_disposed) { return(_value); } _disposable = changeToken.RegisterChangeCallback(_initializerWithState, null); return(_value); } }