static FormatterCache()
 {
     var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T));
     if (f != null)
     {
         formatter = (global::MessagePack.Formatters.IMessagePackFormatter<T>)f;
     }
 }
示例#2
0
            static FormatterCache()
            {
                var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T));

                if (f != null)
                {
                    Formatter = (global::MessagePack.Formatters.IMessagePackFormatter <T>)f;
                }
            }
示例#3
0
            static FormatterCache()
            {
                var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T));

                if (f != null)
                {
                    formatter = (global::MessagePack.Formatters.IMessagePackFormatter <T>)f;
                    return;
                }

                f = StandardResolver.Instance.GetFormatter <T>();
                if (f != null)
                {
                    formatter = (global::MessagePack.Formatters.IMessagePackFormatter <T>)f;
                    return;
                }
            }
        public override bool TryGet <T>(out IMessagePackFormatter <T> formatter)
        {
            if (!base.TryGet(out formatter))
            {
                global::MessagePack.Formatters.IMessagePackFormatter <T> formatterInner = Resolver.GetFormatter <T>();

                if (formatterInner != null)
                {
                    formatter = new MessagePackFormatterWrapper <T>(this, Context, formatterInner, Resolver);

                    Formatters.Add(typeof(T), formatter);

                    return(true);
                }
            }

            return(formatter != null);
        }
 public MessagePackFormatterWrapper(IMessagePackProvider provider, IMessagePackContext context, global::MessagePack.Formatters.IMessagePackFormatter <T> formatter, IFormatterResolver resolver) : base(provider, context)
 {
     Formatter = formatter ?? throw new ArgumentNullException(nameof(formatter));
     Resolver  = resolver ?? throw new ArgumentNullException(nameof(resolver));
 }