Ejemplo n.º 1
0
        public void FluentSerialization_IdentifiesBlittableProperties()
        {
            var conf = new SerializationConfiguration();

            conf.ConfigureType <TestType>()
            .ConfigureProperty(x => x.IntColumn, x => x.ExcludeFromSerialization    = true)
            .ConfigureProperty(x => x.DecColumn, x => x.ExcludeFromSerialization    = true)
            .ConfigureProperty(x => x.TimeColumn, x => x.ExcludeFromSerialization   = true)
            .ConfigureProperty(x => x.EnumColumn, x => x.ExcludeFromSerialization   = true)
            .ConfigureProperty(x => x.StructColumn, x => x.ExcludeFromSerialization = true)
            ;

            var properties = conf.Types[typeof(TestType)].Properties;

            Assert.Contains(typeof(TestType).GetProperty("IntColumn"), properties.Keys);
            Assert.Contains(typeof(TestType).GetProperty("DecColumn"), properties.Keys);
            Assert.Contains(typeof(TestType).GetProperty("TimeColumn"), properties.Keys);
            Assert.Contains(typeof(TestType).GetProperty("EnumColumn"), properties.Keys);
            Assert.Contains(typeof(TestType).GetProperty("StructColumn"), properties.Keys);

            foreach (var propertyConfiguration in properties.Values)
            {
                Assert.True(propertyConfiguration.ExcludeFromSerialization);
            }
        }
Ejemplo n.º 2
0
        public void FluentSerialization_IdentifiesReferenceProperties()
        {
            var conf = new SerializationConfiguration();

            conf.ConfigureType <TestType>()
            .ConfigureProperty(x => x.StrColumn, x => x.ExcludeFromSerialization   = true)
            .ConfigureProperty(x => x.ClassColumn, x => x.ExcludeFromSerialization = true)
            ;

            var properties = conf.Types[typeof(TestType)].Properties;

            Assert.Contains(typeof(TestType).GetProperty("StrColumn"), properties.Keys);
            Assert.Contains(typeof(TestType).GetProperty("ClassColumn"), properties.Keys);

            foreach (var propertyConfiguration in properties.Values)
            {
                Assert.True(propertyConfiguration.ExcludeFromSerialization);
            }
        }