public OrleansHttpGatewayMiddleware(RequestDelegate next, IGrainFactory grainFactory,
                                            IOptions <OrleansHttpGatewayOptions> config)
        {
            if (grainFactory == null)
            {
                throw new ArgumentNullException(nameof(grainFactory));
            }
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            this._next = next;

            _grainTypeProvider =
                new CachedGrainTypeProvider(
                    new CompositeGrainTypeProvider(
                        config.Value.Assemblies.Select(x => new AssemblyBasedGrainTypeProvider(x))
                        ));

            _serializer             = JsonSerializer.Create(config.Value.JsonSerializerSettings);
            _grainReferenceProvider = new ExpressionBasedGrainReferenceProvider(grainFactory);
            _grainInvoker           = new DynamicGrainMethodInvoker(
                new IParameterBinder[]
            {
                new JsonBodyParameterBinder(_serializer),       //order is important here, we expect application/json requests
                new NamedQueryStringParameterBinder(_serializer),
            });
        }
Ejemplo n.º 2
0
 public CachedGrainTypeProvider(IGrainTypeProvider inner)
 {
     _inner = inner;
 }