示例#1
0
        /// <summary>
        /// Uses pipe model provider
        /// </summary>
        public WebSocketServerBuilder UsePipeModelProvider(IJsonModelSerializer serializer = null)
        {
            if (serializer == null)
            {
                serializer = new NewtonsoftJsonModelSerializer();
            }

            if (_handler.Observer.HandlersRegistered)
            {
                throw new InvalidOperationException("You must use Use...Provider methods before Add..Handler(s) methods. Change method call order.");
            }

            _handler.Observer.Provider = new PipeModelProvider(serializer);

            if (_services != null)
            {
                _services.AddSingleton(_handler.Observer.Provider);
            }

            return(this);
        }
 /// <summary>
 /// Creates new pipe model provider
 /// </summary>
 public PipeModelProvider(IJsonModelSerializer serializer)
 {
     Serializer = serializer;
 }