Esempio n. 1
0
        public void PropertyTest3()
        {
            //A valueSerializer exists on the property and on the type; the ValueSerializer on the property is preferred.
            //In the event that the ValueSerializer does not convert to string, the ValueSerializer on the type will be called.
            Bicycle bike = new Bicycle {
                Brand = "RoadRanger", Year = 2002
            };
            string generated = SaveToString(new VSContainer2 {
                Vehicle = bike
            });
            string expected =
                @"<VSContainer2 xmlns=""clr-namespace:Test.Elements;assembly=XamlTestClasses"">
  <VSContainer2.Vehicle>
    <Bicycle>a RoadRanger bicycle made in 2002</Bicycle>
  </VSContainer2.Vehicle>
</VSContainer2>";

            Assert.AreEqual(expected, generated);
        }
        public override string ConvertToString(object value, IValueSerializerContext context)
        {
            Bicycle bike = value as Bicycle;

            return("a " + bike.Brand + " bicycle made in " + bike.Year);
        }