Exemplo n.º 1
0
            public IChangeToken Watch(string filter)
            {
                if (filter.IndexOf('*') >= 0)
                {
                    throw new ArgumentException($"Wildcards are not allowed", nameof(filter));
                }

                var filePath = Path.Combine(_root, filter);

                lock (_gate)
                {
                    if (_changeTokens == null)
                    {
                        _changeTokens = new Dictionary <string, PollingFileChangeToken>(StringComparer.OrdinalIgnoreCase);
                    }

                    if (!_changeTokens.TryGetValue(filePath, out var changeToken))
                    {
                        changeToken = new PollingFileChangeToken(filePath);
                        _changeTokens.Add(filePath, changeToken);
                    }

                    return(changeToken);
                }
            }
Exemplo n.º 2
0
 public DisposableChangeCallback(PollingFileChangeToken pollingFileChangeToken, int callbackId)
 {
     _changeToken = pollingFileChangeToken;
     _callbackId  = callbackId;
 }