/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="next"></param>
 /// <param name="options"></param>
 public WebSocketMiddleware(RequestDelegate next, IOptions <WebSocketOptions> options) :
     base(options.Value.IoTHubOwnerConnectionString)
 {
     _uri    = options.Value.PublicEndpoint;
     _secure = _uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase);
     _next   = next;
     DefaultProvider.Set(this);
 }
 /// <summary>
 /// Get a provider instance
 /// </summary>
 /// <returns></returns>
 public static IProvider Get()
 {
     if (_provider != null)
     {
         return(_provider);
     }
     lock (_lock) {
         if (_provider == null)
         {
             var cs = Environment.GetEnvironmentVariable("_HUB_CS");
             if (cs != null)
             {
                 _provider = new IoTHubProvider(cs);
             }
             else
             {
                 _provider = new DefaultProvider();
             }
         }
         return(_provider);
     }
 }