コード例 #1
0
		public void RootObjectInstance ()
		{
			// bug #689548
			var obj = new RootObjectInstanceTestClass ();
			RootObjectInstanceTestClass result;
			
			var rsettings = new XamlXmlReaderSettings ();
			
			var xml = String.Format (@"<RootObjectInstanceTestClass Property=""Test"" xmlns=""clr-namespace:MonoTests.System.Xaml;assembly={0}""></RootObjectInstanceTestClass>", GetType ().Assembly.GetName ().Name);
			using (var reader = new XamlXmlReader (new StringReader (xml), rsettings)) {
				var wsettings = new XamlObjectWriterSettings ();
				wsettings.RootObjectInstance = obj;
				using (var writer = new XamlObjectWriter (reader.SchemaContext, wsettings)) {
					XamlServices.Transform (reader, writer, false);
					result = (RootObjectInstanceTestClass) writer.Result;
				}
			}
			
			Assert.AreEqual (obj, result, "#1");
			Assert.AreEqual ("Test", obj.Property, "#2");
		}
コード例 #2
0
        public void RootObjectInstance()
        {
            // bug #689548
            var obj = new RootObjectInstanceTestClass();
            RootObjectInstanceTestClass result;

            var rsettings = new XamlXmlReaderSettings();

            var xml = String.Format(@"<RootObjectInstanceTestClass Property=""Test"" xmlns=""clr-namespace:MonoTests.System.Xaml;assembly={0}""></RootObjectInstanceTestClass>", GetType().GetTypeInfo().Assembly.GetName().Name);

            using (var reader = new XamlXmlReader(new StringReader(xml), rsettings)) {
                var wsettings = new XamlObjectWriterSettings();
                wsettings.RootObjectInstance = obj;
                using (var writer = new XamlObjectWriter(reader.SchemaContext, wsettings)) {
                    XamlServices.Transform(reader, writer, false);
                    result = (RootObjectInstanceTestClass)writer.Result;
                }
            }

            Assert.AreEqual(obj, result, "#1");
            Assert.AreEqual("Test", obj.Property, "#2");
        }