Пример #1
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _provider?.Dispose();
                    _provider = null;
                }
                disposedValue = true;
            }
        }
Пример #2
0
 /// <summary>
 /// Create a statsd client
 /// </summary>
 /// <param name="options">client options </param>
 /// <param name="provider">provider, defaults to udp if none is passed</param>
 public Statsd(StatsdOptions options, BaseCommunicationProvider provider = null)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     if (provider == null)
     {
         provider = new Udp();
     }
     if (string.IsNullOrEmpty(options.HostOrIp))
     {
         options.LogEvent("No host or ip provided, failing back to null output", EventType.Error);
         _provider = new NullChannel();
     }
     if (options.Port < 0)
     {
         options.LogEvent("port provided, failing back to null output", EventType.Error);
         _provider = new NullChannel();
     }
     this.options = options;
     _provider    = provider.Construct(options);
 }