Exemplo n.º 1
0
 /// <summary>
 /// Replaces the default serializer with MessagePack.
 /// </summary>
 public static IClientBuilder UseMessagePack(this IClientBuilder builder, MessagePackFormat format = MessagePackFormat.Normal)
 {
     builder.Register(
         pipe: p => { },
         ioc: di => di.AddSingleton <ISerializer, MessagePackSerializerWorker>(resolver => new MessagePackSerializerWorker(format)));
     return(builder);
 }
Exemplo n.º 2
0
        public override void Configure(Container container)
        {
            ConfigureRoutes();
            ConfigureDependencies(container);
            ConfigureNotFound();

            SetConfig(new EndpointHostConfig {
                DebugMode = false
            });

            log4net.Config.XmlConfigurator.Configure();
            MessagePackFormat.Register(this);
        }
Exemplo n.º 3
0
        public MessagePackSerializerWorker(MessagePackFormat format)
        {
            Type tp;

            if (format == MessagePackFormat.LZ4Compression)
            {
                tp = typeof(LZ4MessagePackSerializer);
            }
            else
            {
                tp = typeof(MessagePackSerializer);
            }

            _deserializeType = tp
                               .GetMethod(nameof(MessagePackSerializer.Deserialize), new[] { typeof(byte[]) });
            _serializeType = tp
                             .GetMethods()
                             .FirstOrDefault(s => s.Name == nameof(MessagePackSerializer.Serialize) && s.ReturnType == typeof(byte[]));
        }