コード例 #1
0
 public static IServiceCollection AddFusionWebSocketServer(this IServiceCollection services,
                                                           WebSocketServer.Options options)
 {
     services.TryAddSingleton(options);
     services.TryAddSingleton <WebSocketServer>();
     return(services.AddFusionServerCore());
 }
コード例 #2
0
        // ConfigureXxx

        public FusionWebSocketServerBuilder ConfigureWebSocketServer(
            WebSocketServer.Options options)
        {
            var serviceDescriptor = new ServiceDescriptor(
                typeof(WebSocketServer.Options),
                options);

            Services.Replace(serviceDescriptor);
            return(this);
        }
コード例 #3
0
 public static IServiceCollection AddFusionWebSocketServer(this IServiceCollection services,
                                                           Action <IServiceProvider, WebSocketServer.Options>?optionsBuilder = null)
 {
     services.TryAddSingleton(c => {
         var options = new WebSocketServer.Options();
         optionsBuilder?.Invoke(c, options);
         return(options);
     });
     services.TryAddSingleton <WebSocketServer>();
     return(services.AddFusionServerCore());
 }
コード例 #4
0
        public FusionWebSocketServerBuilder ConfigureWebSocketServer(
            Action <IServiceProvider, WebSocketServer.Options> optionsBuilder)
        {
            var serviceDescriptor = new ServiceDescriptor(
                typeof(WebSocketServer.Options),
                c => {
                var options = new WebSocketServer.Options();
                optionsBuilder.Invoke(c, options);
                return(options);
            },
                ServiceLifetime.Singleton);

            Services.Replace(serviceDescriptor);
            return(this);
        }