/// <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);
 }
        public override void Configure(Container container)
        {
            ConfigureRoutes();
            ConfigureDependencies(container);
            ConfigureNotFound();

            SetConfig(new EndpointHostConfig {
                DebugMode = false
            });

            log4net.Config.XmlConfigurator.Configure();
            MessagePackFormat.Register(this);
        }
Exemple #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[]));
        }