Esempio n. 1
0
 public AspNetCoreServiceMethodBinder(
     ServiceMethodProviderContext <TService> context,
     IMarshallerFactory marshallerFactory)
 {
     _context          = context;
     MarshallerFactory = marshallerFactory;
 }
Esempio n. 2
0
 private static byte[] SerializeInternal <T>(IMarshallerFactory factory, object value)
 {
     using (var context = new DefaultSerializationContext())
     {
         factory.CreateMarshaller <T>().ContextualSerializer((T)value, context);
         return(context.GetContent());
     }
 }
Esempio n. 3
0
 public SelfHostServiceMethodBinder(
     IMarshallerFactory marshallerFactory,
     Func <TService> serviceFactory,
     ServerServiceDefinition.Builder builder)
 {
     MarshallerFactory = marshallerFactory;
     _serviceFactory   = serviceFactory;
     _builder          = builder;
 }
Esempio n. 4
0
        public ErrorHandlerServerCallInterceptorFactory(
            IMarshallerFactory marshallerFactory,
            Func <IServiceProvider, IServerErrorHandler> errorHandlerFactory)
        {
            marshallerFactory.AssertNotNull(nameof(marshallerFactory));

            _marshallerFactory   = marshallerFactory;
            _errorHandlerFactory = errorHandlerFactory;
        }
Esempio n. 5
0
        public ServerCallErrorInterceptor(
            IServerErrorHandler errorHandler,
            IMarshallerFactory marshallerFactory)
        {
            errorHandler.AssertNotNull(nameof(errorHandler));
            marshallerFactory.AssertNotNull(nameof(marshallerFactory));

            _errorHandler      = errorHandler;
            _marshallerFactory = marshallerFactory;
        }
Esempio n. 6
0
 public AspNetCoreServiceMethodBinder(
     ServiceMethodProviderContext <TService> context,
     IMarshallerFactory marshallerFactory,
     ServiceMethodFilterRegistration filterRegistration,
     bool requiresGrpcMarker)
 {
     _context            = context;
     _filterRegistration = filterRegistration;
     _requiresGrpcMarker = requiresGrpcMarker;
     MarshallerFactory   = marshallerFactory;
 }
Esempio n. 7
0
        public ClientCallErrorInterceptor(
            IClientErrorHandler errorHandler,
            IMarshallerFactory marshallerFactory,
            ILogger?logger)
        {
            errorHandler.AssertNotNull(nameof(errorHandler));
            marshallerFactory.AssertNotNull(nameof(marshallerFactory));

            ErrorHandler      = errorHandler;
            MarshallerFactory = marshallerFactory;
            _logger           = logger;
        }
Esempio n. 8
0
        public ServiceModelGrpcServerCallTest(IMarshallerFactory marshallerFactory, SomeObject payload)
        {
            var builder = new WebHostBuilder()
                          .UseStartup(_ => new Startup(marshallerFactory));

            _server = new TestServer(builder);
            _client = _server.CreateClient();

            _request = new StubHttpRequest(
                _client,
                "/ITestService/PingPong",
                MessageSerializer.Create(marshallerFactory, new Message <SomeObject>(payload)));
        }
Esempio n. 9
0
        public ServiceModelGrpcClientCallTest(IMarshallerFactory marshallerFactory, SomeObject payload)
        {
            _payload     = payload;
            _httpHandler = new StubHttpMessageHandler(marshallerFactory, new Message <SomeObject>(payload));
            _channel     = GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions {
                HttpHandler = _httpHandler
            });

            var clientFactory = new ClientFactory(new ServiceModelGrpcClientOptions {
                MarshallerFactory = marshallerFactory
            });

            _proxy = clientFactory.CreateClient <ITestService>(_channel);
        }
Esempio n. 10
0
        public static object DeserializeHeader(this IMarshallerFactory factory, Type valueType, byte[] valueContent)
        {
            valueType.AssertNotNull(nameof(valueType));

            if (valueType == typeof(byte[]))
            {
                return(valueContent);
            }

            return(typeof(MarshallerFactoryExtensions)
                   .StaticMethod(nameof(DeserializeInternal))
                   .MakeGenericMethod(valueType)
                   .CreateDelegate <Func <IMarshallerFactory, byte[], object> >()
                   .Invoke(factory, valueContent));
        }
Esempio n. 11
0
        public static byte[] SerializeHeader(this IMarshallerFactory factory, object value)
        {
            factory.AssertNotNull(nameof(factory));
            value.AssertNotNull(nameof(value));

            if (value is byte[] buffer)
            {
                return(buffer);
            }

            return(typeof(MarshallerFactoryExtensions)
                   .StaticMethod(nameof(SerializeInternal))
                   .MakeGenericMethod(value.GetType())
                   .CreateDelegate <Func <IMarshallerFactory, object, byte[]> >()
                   .Invoke(factory, value));
        }
Esempio n. 12
0
        public ServiceModelGrpcCombinedCallTest(IMarshallerFactory marshallerFactory, SomeObject payload)
        {
            _payload = payload;

            var builder = new WebHostBuilder().UseStartup(_ => new Startup(marshallerFactory));

            _server = new TestServer(builder);
            _client = _server.CreateClient();

            _channel = GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions {
                HttpClient = _client
            });
            _clientFactory = new ClientFactory(new ServiceModelGrpcClientOptions {
                MarshallerFactory = marshallerFactory
            });
            _proxy = _clientFactory.CreateClient <ITestService>(_channel);
        }
Esempio n. 13
0
 public static byte[] Create(IMarshallerFactory marshallerFactory, object data) => Create(MarshallerSerialize(marshallerFactory, data));
Esempio n. 14
0
        private static object DeserializeInternal <T>(IMarshallerFactory factory, byte[] content)
        {
            var result = factory.CreateMarshaller <T>().ContextualDeserializer(new DefaultDeserializationContext(content));

            return(result !);
        }
Esempio n. 15
0
 public ContractMock(IMarshallerFactory marshallerFactory)
 {
     MarshallerFactory = marshallerFactory;
 }
Esempio n. 16
0
 public void Initialize(IMarshallerFactory marshallerFactory, Func <CallOptions>?defaultCallOptionsFactory)
 {
     MarshallerFactory         = marshallerFactory;
     DefaultCallOptionsFactory = defaultCallOptionsFactory;
 }
Esempio n. 17
0
 internal abstract IUnaryCallTest CreateServiceModelGrpc(IMarshallerFactory marshallerFactory, SomeObject payload);
Esempio n. 18
0
 public StubHttpMessageHandler(IMarshallerFactory marshallerFactory, object response)
 {
     _responsePayload = MessageSerializer.Create(marshallerFactory, response);
 }
Esempio n. 19
0
 public static Metadata SerializeMethodInput <T1, T2>(IMarshallerFactory marshallerFactory, T1 value1, T2 value2)
 {
     return(CompatibilityTools.SerializeMethodInputHeader(marshallerFactory.CreateMarshaller <Message <T1, T2> >(), new Message <T1, T2>(value1, value2)));
 }
Esempio n. 20
0
 public Startup(IMarshallerFactory marshallerFactory)
 {
     _marshallerFactory = marshallerFactory;
 }
Esempio n. 21
0
 internal override IUnaryCallTest CreateServiceModelGrpc(IMarshallerFactory marshallerFactory, SomeObject payload)
 {
     return(new ServiceModelGrpcServerCallTest(marshallerFactory, payload));
 }
Esempio n. 22
0
        public static T DeserializeMethodInput <T>(IMarshallerFactory marshallerFactory, Metadata?requestHeaders)
        {
            var message = CompatibilityTools.DeserializeMethodInputHeader(marshallerFactory.CreateMarshaller <Message <T> >(), requestHeaders);

            return(message.Value1);
        }