示例#1
0
        public byte[] EncodeAsUtf8Bytes <T>(T payload, DateTimeOffset?expire, Action <T, JwtWriter> payloadWriter)
        {
            var buffer = GetWriter();

            try
            {
                var writer = new JwtWriter(buffer, signAlgorithm, expire);
                payloadWriter(payload, writer);
                return(buffer.ToUtf8Bytes());
            }
            finally
            {
                buffer.Reset();
            }
        }
示例#2
0
        public string Encode <T>(T payload, DateTimeOffset?expire, Action <T, JwtWriter> payloadWriter)
        {
            var buffer = GetWriter();

            try
            {
                var writer = new JwtWriter(buffer, signAlgorithm, expire);
                payloadWriter(payload, writer);
                return(buffer.ToString());
            }
            finally
            {
                buffer.Reset();
            }
        }
示例#3
0
        public void Encode <T>(IBufferWriter <byte> bufferWriter, T payload, DateTimeOffset?expire, Action <T, JwtWriter> payloadWriter)
        {
            var writer = new JwtWriter(bufferWriter, signAlgorithm, expire);

            payloadWriter(payload, writer);
        }