public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            Claim source = (Claim)value;

            var target = new ClaimLite(source);
            serializer.Serialize(writer, target);
        }
Esempio n. 2
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            Claim source = (Claim)value;

            var target = new ClaimLite(source);

            serializer.Serialize(writer, target);
        }
Esempio n. 3
0
    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);
    }
        public void CheckClient()
        {
            var original = ObjectMother.CreateClient();
            var document = original.ToDocument();
            var restored = document.ToModel();

            restored.ShouldBeEquivalentTo(original, opt =>
            {
                opt.Excluding(c => c.Claims);
                return opt;
            });

            Assert.AreEqual(original.Claims.Count, restored.Claims.Count);

            //manually comparing claims
            foreach (var claim in original.Claims)
            {
                var claimLite = new ClaimLite(claim);
                Assert.True(restored.Claims.Exists(c => new ClaimLite(c).Equals(claimLite)), "could not match claim: " + claim.ToString());
            }
        }
        public void CheckClient()
        {
            var original = ObjectMother.CreateClient();
            var document = original.ToDocument();
            var restored = document.ToModel();

            restored.ShouldBeEquivalentTo(original, opt =>
            {
                opt.Excluding(c => c.Claims);
                return(opt);
            });

            Assert.AreEqual(original.Claims.Count, restored.Claims.Count);

            //manually comparing claims
            foreach (var claim in original.Claims)
            {
                var claimLite = new ClaimLite(claim);
                Assert.True(restored.Claims.Exists(c => new ClaimLite(c).Equals(claimLite)), "could not match claim: " + claim.ToString());
            }
        }