Esempio n. 1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var source = (Claim)value;

            var target = new ClaimLite
            {
                Type      = source.Type,
                Value     = source.Value,
                ValueType = source.ValueType
            };

            serializer.Serialize(writer, target);
        }
        public override void Write(Utf8JsonWriter writer, Claim value, JsonSerializerOptions options)
        {
            var target = new ClaimLite
            {
                Type      = value.Type,
                Value     = value.Value,
                ValueType = value.ValueType
            };

            if (target.ValueType == ClaimValueTypes.String)
            {
                target.ValueType = null;
            }

            JsonSerializer.Serialize(writer, target, options);
        }
Esempio n. 3
0
        public override void Write(Utf8JsonWriter writer, ClaimsPrincipal value, JsonSerializerOptions options)
        {
            var target = new ClaimsPrincipalLite
            {
                AuthenticationType = value.Identity.AuthenticationType,
                Claims             = value.Claims.Select(x =>
                {
                    var cl = new ClaimLite {
                        Type = x.Type, Value = x.Value, ValueType = x.ValueType
                    };
                    if (cl.ValueType == ClaimValueTypes.String)
                    {
                        cl.ValueType = null;
                    }
                    return(cl);
                }).ToArray()
            };

            JsonSerializer.Serialize(writer, target, options);
        }