public void Merge(ServerRuntimeConfiguration other)
        {
            if (other == null)
            {
                return;
            }

            if (other.AvailableSerializers != null)
            {
                AvailableSerializers = other.AvailableSerializers;
            }
            if (other.ExceptionSerializer != null)
            {
                ExceptionSerializer = other.ExceptionSerializer;
            }
            if (other.Options != null)
            {
                Options = other.Options;
            }
            if (other.DefaultSerializer != null)
            {
                DefaultSerializer = other.DefaultSerializer;
            }
            if (other.ErrorHandler != null)
            {
                ErrorHandler = other.ErrorHandler;
            }
        }
        public void Merge(ServerRuntimeConfiguration other)
        {
            if (other == null)
            {
                return;
            }

            if (other.Serializer != null)
            {
                Serializer = other.Serializer;
            }
            if (other.ExceptionWrapper != null)
            {
                ExceptionWrapper = other.ExceptionWrapper;
            }
            if (other.Options != null)
            {
                Options = other.Options;
            }
            if (other.Serializer != null)
            {
                Serializer = other.Serializer;
            }
            if (other.ErrorHandler != null)
            {
                ErrorHandler = other.ErrorHandler;
            }
        }
        public void Merge(ServerRuntimeConfiguration other)
        {
            if (other == null)
            {
                return;
            }

            if (other.AvailableSerializers != null)
            {
                AvailableSerializers = other.AvailableSerializers;
            }
            if (other.ExceptionWrapper != null)
            {
                ExceptionWrapper = other.ExceptionWrapper;
            }
            if (other.Options != null)
            {
                Options = other.Options;
            }
            if (other.DefaultSerializer != null)
            {
                DefaultSerializer = other.DefaultSerializer;
            }
            if (other.ErrorHandler != null)
            {
                ErrorHandler = other.ErrorHandler;
            }
        }
Example #4
0
 public static IContractInvoker Use <TContract>(
     this IBoltRouteHandler bolt,
     IInstanceProvider instanceProvider,
     Action <ConfigureContractContext> configure = null,
     ServerRuntimeConfiguration configuration    = null)
 {
     return(bolt.Use(typeof(TContract), instanceProvider, configure, configuration));
 }
Example #5
0
 public static IContractInvoker UseSession <TContract, TContractImplementation>(
     this IBoltRouteHandler bolt,
     ISessionFactory sessionFactory,
     Action <ConfigureContractContext> configure = null,
     ServerRuntimeConfiguration configuration    = null) where TContractImplementation : TContract
 {
     return(bolt.Use <TContract>(InstanceProvider.Session.From <TContractImplementation>(sessionFactory), configure, configuration));
 }
        public ServerRuntimeConfiguration(ServerRuntimeConfiguration other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            Serializer = other.Serializer;
            ExceptionWrapper = other.ExceptionWrapper;
            Options = other.Options;
        }
        public void Init(HttpContext httpContext, ServerRuntimeConfiguration configuration)
        {
            HttpContext = httpContext;

            if (Configuration == null)
            {
                Configuration = new ServerRuntimeConfiguration();
            }

            Configuration.Merge(configuration);
        }
Example #8
0
        public static IContractInvoker Use(
            this IBoltRouteHandler bolt,
            Type contract,
            IInstanceProvider instanceProvider,
            Action <ConfigureContractContext> configure = null,
            ServerRuntimeConfiguration configuration    = null)
        {
            if (contract == null)
            {
                throw new ArgumentNullException(nameof(contract));
            }

            if (bolt == null)
            {
                throw new ArgumentNullException(nameof(bolt));
            }

            if (instanceProvider == null)
            {
                throw new ArgumentNullException(nameof(instanceProvider));
            }

            var factory = bolt.ApplicationServices.GetRequiredService <IContractInvokerFactory>();

            configuration = configuration ?? new ServerRuntimeConfiguration(bolt.Configuration);

            IContractInvoker invoker = factory.Create(BoltFramework.GetContract(contract), instanceProvider, configuration);
            IPipeline <ServerActionContext> pipeline = null;

            if (configure != null)
            {
                ConfigureContractContext ctxt = new ConfigureContractContext(invoker, bolt.ApplicationServices);
                configure.Invoke(ctxt);

                if (ctxt.Middlewares.Any())
                {
                    pipeline = bolt.ApplicationServices.GetRequiredService <IServerPipelineBuilder>().Build(ctxt.Middlewares);
                }
            }

            if (pipeline != null)
            {
                invoker.Pipeline = pipeline;
            }
            else if (invoker.Pipeline == null)
            {
                // build default pipeline
                invoker.Pipeline = bolt.ApplicationServices.GetRequiredService <IServerPipelineBuilder>().Build();
            }
            bolt.Add(invoker);

            return(invoker);
        }
Example #9
0
        public static IContractInvoker UseMemorySession <TContract, TContractImplementation>(
            this IBoltRouteHandler bolt,
            Action <ConfigureContractContext> configure = null) where TContractImplementation : TContract
        {
            var config  = new ServerRuntimeConfiguration(bolt.Configuration);
            var factory = new MemorySessionFactory(
                config,
                bolt.ApplicationServices.GetRequiredService <IServerSessionHandler>(),
                bolt.ApplicationServices.GetRequiredService <ILoggerFactory>());

            return(bolt.Use <TContract>(InstanceProvider.Session.From <TContractImplementation>(factory), configure, config));
        }
Example #10
0
        public static IContractInvoker UseDistributedSession <TContract, TContractImplementation>(
            this IBoltRouteHandler bolt,
            ISessionStore sessionStore,
            Action <ConfigureContractContext> configure = null) where TContractImplementation : TContract
        {
            var config  = new ServerRuntimeConfiguration(bolt.Configuration);
            var factory = new DistributedSessionFactory(
                config,
                sessionStore,
                bolt.ApplicationServices.GetRequiredService <IServerSessionHandler>());

            return(bolt.UseSession <TContract, TContractImplementation>(factory, configure, config));
        }
        public ServerRuntimeConfiguration(ServerRuntimeConfiguration other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            AvailableSerializers = other.AvailableSerializers;
            DefaultSerializer    = other.DefaultSerializer;
            ExceptionSerializer  = other.ExceptionSerializer;
            Options      = other.Options;
            ErrorHandler = other.ErrorHandler;
        }
        public ServerRuntimeConfiguration(ServerRuntimeConfiguration other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            AvailableSerializers = other.AvailableSerializers;
            DefaultSerializer = other.DefaultSerializer;
            ExceptionWrapper = other.ExceptionWrapper;
            Options = other.Options;
            ErrorHandler = other.ErrorHandler;
        }
Example #13
0
        public BoltRouteHandler(
            ILoggerFactory factory,
            ServerRuntimeConfiguration defaultConfiguration,
            IBoltMetadataHandler metadataHandler,
            IServiceProvider applicationServices,
            IActionResolver actionResolver,
            IContractInvokerSelector contractResolver)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            Logger              = factory.CreateLogger <BoltRouteHandler>();
            MetadataHandler     = metadataHandler;
            ApplicationServices = applicationServices ?? throw new ArgumentNullException(nameof(applicationServices));
            Configuration       = defaultConfiguration ?? throw new ArgumentNullException(nameof(defaultConfiguration));
            _actionResolver     = actionResolver ?? throw new ArgumentNullException(nameof(actionResolver));
            _contractResolver   = contractResolver ?? throw new ArgumentNullException(nameof(contractResolver));
        }
Example #14
0
 public ContractInvoker()
 {
     Configuration = new ServerRuntimeConfiguration();
 }
Example #15
0
        public IContractInvoker Create(ContractMetadata contract, IInstanceProvider instanceProvider, ServerRuntimeConfiguration configuration)
        {
            if (contract == null)
            {
                throw new ArgumentNullException(nameof(contract));
            }

            if (instanceProvider == null)
            {
                throw new ArgumentNullException(nameof(instanceProvider));
            }

            if (instanceProvider == null)
            {
                throw new ArgumentNullException(nameof(instanceProvider));
            }

            return(new ContractInvoker(configuration)
            {
                Contract = contract, InstanceProvider = instanceProvider
            });
        }
Example #16
0
 public ContractInvoker(ServerRuntimeConfiguration configuration)
 {
     Configuration = configuration ?? new ServerRuntimeConfiguration();
 }