当前位置: 首页>>代码示例>>C#>>正文


C# XamlReader.Read方法代码示例

本文整理汇总了C#中XamlReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# XamlReader.Read方法的具体用法?C# XamlReader.Read怎么用?C# XamlReader.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XamlReader的用法示例。


在下文中一共展示了XamlReader.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read_String

		protected void Read_String (XamlReader r)
		{
			Assert.AreEqual (XamlNodeType.None, r.NodeType, "#1");
			Assert.IsNull (r.Member, "#2");
			Assert.IsNull (r.Namespace, "#3");
			Assert.IsNull (r.Member, "#4");
			Assert.IsNull (r.Type, "#5");
			Assert.IsNull (r.Value, "#6");

			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			Assert.IsNotNull (r.Type, "#23");
			Assert.AreEqual (new XamlType (typeof (string), r.SchemaContext), r.Type, "#23-2");
			Assert.IsNull (r.Namespace, "#25");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.IsNotNull (r.Member, "#33");
			Assert.AreEqual (XamlLanguage.Initialization, r.Member, "#33-2");
			Assert.IsNull (r.Type, "#34");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("foo", r.Value, "#43");
			Assert.IsNull (r.Member, "#44");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");
			Assert.IsNull (r.Type, "#53");
			Assert.IsNull (r.Member, "#54");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");
			Assert.IsNull (r.Type, "#63");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:47,代码来源:XamlReaderTestBase.cs

示例2: Read_DeferredLoadingContainerMember

		protected void Read_DeferredLoadingContainerMember(XamlReader r)
		{
			Assert.IsTrue(r.Read(), "ns#1-1");
			Assert.AreEqual(XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#1-2");
			Assert.IsNotNull(r.Namespace, "ns#1-3");
			Assert.AreEqual("", r.Namespace.Prefix, "ns#1-4");
			var assns = "clr-namespace:MonoTests.Portable.Xaml;assembly=" + GetType().Assembly.GetName().Name;
			Assert.AreEqual(assns, r.Namespace.Namespace, "ns#1-5");

			// t:DeferredLoadingContainerMember
			Assert.IsTrue(r.Read(), "so#1-1");
			Assert.AreEqual(XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType(typeof(DeferredLoadingContainerMember), r.SchemaContext);
			Assert.AreEqual(xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase(r);

			Assert.IsTrue(r.Read(), "sm1#1");
			Assert.AreEqual(XamlNodeType.StartMember, r.NodeType, "sm1#2");
			Assert.AreEqual(xt.GetMember("Child"), r.Member, "sm1#3");

			Assert.IsTrue(r.Read(), "v#1-1");
			Assert.AreEqual(XamlNodeType.StartObject, r.NodeType, "v#1-2");
			Assert.AreEqual(xt = r.SchemaContext.GetXamlType(typeof(DeferredLoadingChild)), r.Type, "v#1-3");

			Assert.IsTrue(r.Read(), "sm1#1");
			Assert.AreEqual(XamlNodeType.StartMember, r.NodeType, "sm1#2");
			Assert.AreEqual(xt.GetMember("Foo"), r.Member, "sm1#3");

			Assert.IsTrue(r.Read(), "em#1-1");
			Assert.AreEqual(XamlNodeType.Value, r.NodeType, "em#1-2");
			Assert.AreEqual("Some value", r.Value, "em#1-2");

			Assert.IsTrue(r.Read(), "em#1-1");
			Assert.AreEqual(XamlNodeType.EndMember, r.NodeType, "em#1-2");

			Assert.IsTrue(r.Read(), "em#1-1");
			Assert.AreEqual(XamlNodeType.EndObject, r.NodeType, "em#1-2");

			Assert.IsTrue(r.Read(), "em#1-1");
			Assert.AreEqual(XamlNodeType.EndMember, r.NodeType, "em#1-2");

			// /t:NullableContainer
			Assert.IsTrue(r.Read(), "eo#1-1");
			Assert.AreEqual(XamlNodeType.EndObject, r.NodeType, "eo#1-2");

			Assert.IsFalse(r.Read(), "end");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:49,代码来源:XamlReaderTestBase.cs

示例3: Read_ArrayExtension2

		// It gives Type member, not PositionalParameters... and no Items member here.
		protected void Read_ArrayExtension2 (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");
//			Assert.IsNull (r.Instance, "#14");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (typeof (ArrayExtension), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23-2");
//			Assert.IsTrue (r.Instance is ArrayExtension, "#26");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (xt.GetMember ("Type"), r.Member, "#33-2");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("x:Int32", r.Value, "#43-2");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:36,代码来源:XamlReaderTestBase.cs

示例4: Read_ArrayList

		protected void Read_ArrayList (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "ns#1-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#1-2");

			var defns = "clr-namespace:System.Collections;assembly=mscorlib";

			Assert.AreEqual (String.Empty, r.Namespace.Prefix, "ns#1-3");
			Assert.AreEqual (defns, r.Namespace.Namespace, "ns#1-4");

			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (typeof (ArrayList), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23");
//			Assert.AreEqual (obj, r.Instance, "#26");
			Assert.IsTrue (xt.IsCollection, "#27");

			if (r is XamlXmlReader)
				ReadBase (r);

			// This assumption on member ordering ("Type" then "Items") is somewhat wrong, and we might have to adjust it in the future.

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (xt.GetMember ("Capacity"), r.Member, "#33");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			// The value is implementation details, not testable.
			//Assert.AreEqual ("3", r.Value, "#43");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#72");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#72-2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "#72-3");

			string [] values = {"5", "-3", "0"};
			for (int i = 0; i < 3; i++) {
				Assert.IsTrue (r.Read (), i + "#73");
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, i + "#73-2");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#74-2");
				Assert.AreEqual (XamlLanguage.Initialization, r.Member, i + "#74-3");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.IsNotNull (r.Value, i + "#75-2");
				Assert.AreEqual (values [i], r.Value, i + "#73-3");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#74-2");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#75-2");
			}

			Assert.IsTrue (r.Read (), "#81");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#82"); // XamlLanguage.Items

			Assert.IsTrue (r.Read (), "#87");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#88");

			Assert.IsFalse (r.Read (), "#89");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:68,代码来源:XamlReaderTestBase.cs

示例5: Read_ListType

		protected void Read_ListType (XamlReader r, bool isObjectReader, bool order = true)
		{

			IEnumerable<NamespaceDeclaration> namespaces = new [] {
				new NamespaceDeclaration ("clr-namespace:System.Collections.Generic;assembly=mscorlib", string.Empty),
				new NamespaceDeclaration ("clr-namespace:" + Compat.Namespace + ";assembly=" + Compat.Namespace, Compat.Prefix),
				new NamespaceDeclaration ("clr-namespace:System;assembly=mscorlib", "s"),
				new NamespaceDeclaration (XamlLanguage.Xaml2006Namespace, "x")
			};

			if (order)
				namespaces = namespaces.OrderBy(n => n.Prefix);
			int count = 0;
			foreach (var ns in namespaces) {
				count++;
				Assert.IsTrue (r.Read (), "ns#{0}-1", count);
				Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#{0}-2", count);
				Assert.IsNotNull (r.Namespace, "ns#{0}-3", count);
				Assert.AreEqual (ns.Prefix, r.Namespace.Prefix, "ns#{0}-3-2", count);
				Assert.AreEqual (ns.Namespace, r.Namespace.Namespace, "ns#{0}-3-3", count);
			}

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (typeof (List<Type>), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23");
			Assert.IsTrue (xt.IsCollection, "#27");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (xt.GetMember ("Capacity"), r.Member, "#33");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("2", r.Value, "#43");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#72");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#72-2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "#72-3");

			string [] values = {"x:Int32", $"Dictionary(s:Type, {Compat.Prefix}:XamlType)"};
			for (int i = 0; i < 2; i++) {
				Assert.IsTrue (r.Read (), i + "#73");
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, i + "#73-2");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#74-2");
				// Here XamlObjectReader and XamlXmlReader significantly differs. (Lucky we can make this test conditional so simply)
				if (isObjectReader)
					Assert.AreEqual (XamlLanguage.PositionalParameters, r.Member, i + "#74-3");
				else
					Assert.AreEqual (XamlLanguage.Type.GetMember ("Type"), r.Member, i + "#74-3");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.IsNotNull (r.Value, i + "#75-2");
				Assert.AreEqual (values [i], r.Value, i + "#73-3");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#74-2");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#75-2");
			}

			Assert.IsTrue (r.Read (), "#81");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#82"); // XamlLanguage.Items
			
			Assert.IsTrue (r.Read (), "#87");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#88");

			Assert.IsFalse (r.Read (), "#89");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:74,代码来源:XamlReaderTestBase.cs

示例6: Read_StaticExtension

		// almost identical to TypeExtension (only type/instance difference)
		protected void Read_StaticExtension (XamlReader r, XamlMember ctorArgMember)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");
//			Assert.IsNull (r.Instance, "#14");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			Assert.AreEqual (new XamlType (typeof (StaticExtension), r.SchemaContext), r.Type, "#23-2");
//			Assert.IsTrue (r.Instance is StaticExtension, "#26");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (ctorArgMember, r.Member, "#33-2");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("FooBar", r.Value, "#43-2");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:35,代码来源:XamlReaderTestBase.cs

示例7: Read_Reference

		protected void Read_Reference (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (typeof (Reference), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23-2");
//			Assert.IsTrue (r.Instance is Reference, "#26");
			Assert.IsNotNull (XamlLanguage.Type.SchemaContext, "#23-3");
			Assert.IsNotNull (r.SchemaContext, "#23-4");
			Assert.AreNotEqual (XamlLanguage.Type.SchemaContext, r.SchemaContext, "#23-5");
			Assert.AreNotEqual (XamlLanguage.Reference.SchemaContext, xt.SchemaContext, "#23-6");
			Assert.AreEqual (XamlLanguage.Reference, xt, "#23-7");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			// unlike TypeExtension there is no PositionalParameters.
			Assert.AreEqual (xt.GetMember ("Name"), r.Member, "#33-2");

			// It is a ContentProperty (besides [ConstructorArgument])
			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("FooBar", r.Value, "#43-2");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:40,代码来源:XamlReaderTestBase.cs

示例8: ReadValue

		void ReadValue(XamlReader r, object value, string label)
		{
			Assert.IsTrue(r.Read(), label + "-1");
			Assert.AreEqual(XamlNodeType.Value, r.NodeType, label + "-2");
			Assert.AreEqual(value, r.Value, label + "-3");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:6,代码来源:XamlReaderTestBase.cs

示例9: ReadAttachedProperty

		void ReadAttachedProperty (XamlReader r, XamlMember xm, string value, string label)
		{
			Assert.IsTrue (r.Read (), label + "#1-1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, label + "#1-2");
			Assert.AreEqual (xm, r.Member, label + "#1-3");

			Assert.IsTrue (r.Read (), label + "#2-1");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, label + "#2-2");
			Assert.AreEqual (value, r.Value, label + "2-3");

			Assert.IsTrue (r.Read (), label + "#3-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, label + "#3-2");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:13,代码来源:XamlReaderTestBase.cs

示例10: Read_AttachedProperty

		protected void Read_AttachedProperty (XamlReader r)
		{
			var at = new XamlType (typeof (Attachable), r.SchemaContext);

			Assert.IsTrue (r.Read (), "ns#1-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#1-2");
			Assert.IsNotNull (r.Namespace, "ns#1-3");
			Assert.AreEqual ("", r.Namespace.Prefix, "ns#1-4");
			var assns = "clr-namespace:MonoTests.Portable.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;
			Assert.AreEqual (assns, r.Namespace.Namespace, "ns#1-5");

			// t:AttachedWrapper
			Assert.IsTrue (r.Read (), "so#1-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType (typeof (AttachedWrapper), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase (r);

			ReadAttachedProperty (r, at.GetAttachableMember ("Foo"), "x", "x");

			// m:Value
			Assert.IsTrue (r.Read (), "sm#2-1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#sm#2-2");
			Assert.AreEqual (xt.GetMember ("Value"), r.Member, "sm#2-3");

			// t:Attached
			Assert.IsTrue (r.Read (), "so#2-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#so#2-2");
			Assert.AreEqual (r.SchemaContext.GetXamlType (typeof (Attached)), r.Type, "so#2-3");

			ReadAttachedProperty (r, at.GetAttachableMember ("Foo"), "y", "y");

			Assert.IsTrue (r.Read (), "eo#2-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#eo#2-2");

			// /m:Value
			Assert.IsTrue (r.Read (), "em#2-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#em#2-2");

			// /t:AttachedWrapper
			Assert.IsTrue (r.Read (), "eo#1-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#1-2");

			Assert.IsFalse (r.Read (), "end");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:47,代码来源:XamlReaderTestBase.cs

示例11: Read_TypeOrTypeExtension2

		protected void Read_TypeOrTypeExtension2 (XamlReader r, Action validateInstance, XamlMember ctorArgMember)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");

			var defns = "clr-namespace:MonoTests.Portable.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;

			Assert.AreEqual (String.Empty, r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (defns, r.Namespace.Namespace, "#13-3:" + r.Namespace.Prefix);

			Assert.IsTrue (r.Read (), "#16");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#17");
			Assert.IsNotNull (r.Namespace, "#18");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#18-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#18-3:" + r.Namespace.Prefix);

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			Assert.AreEqual (new XamlType (typeof (TypeExtension), r.SchemaContext), r.Type, "#23-2");
			if (validateInstance != null)
				validateInstance ();

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (ctorArgMember, r.Member, "#33-2");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("TestClass1", r.Value, "#43-2");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:42,代码来源:XamlReaderTestBase.cs

示例12: Read_ContentPropertyContainer

		protected void Read_ContentPropertyContainer (XamlReader r)
		{
			ReadNamespace (r, String.Empty, "http://www.domain.com/path", "ns#1");
			ReadNamespace (r, "x", XamlLanguage.Xaml2006Namespace, "ns#2");

			// 1:: t:ContentPropertyContainer
			Assert.IsTrue (r.Read (), "so#1-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType (typeof (SecondTest.ContentPropertyContainer), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase (r);

			// 2:: m:Items
			Assert.IsTrue (r.Read (), "sm1#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm1#2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "sm1#3");

			xt = r.SchemaContext.GetXamlType (typeof (SecondTest.SimpleType));
			for (int i = 0; i < 2; i++) {
				// 3:: t:SimpleType
				Assert.IsTrue (r.Read (), "so#x-1" + "." + i);
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#x-2" + "." + i);
				Assert.AreEqual (xt, r.Type, "so#x-3" + "." + i);

				// 4:: m:Key
				Assert.IsTrue (r.Read (), "sm#y1" + "." + i);
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#y2" + "." + i);
				Assert.AreEqual (XamlLanguage.Key, r.Member, "sm#y3" + "." + i);

				// 4:: value
				Assert.IsTrue (r.Read (), "v#y-1" + "." + i);
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#y-2" + "." + i);
				Assert.AreEqual (i == 0 ? "one" : "two", r.Value, "v#y-3" + "." + i);

				// 4:: /m:Key
				Assert.IsTrue (r.Read (), "em#y-1" + "." + i);
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#y-2" + "." + i);

if (i == 0) {

				// 4-2:: m:Items(ContentProperty)
				Assert.IsTrue (r.Read (), "sm#x1" + "." + i);
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#x2" + "." + i);
				Assert.AreEqual (xt.GetMember ("Items"), r.Member, "sm#x3" + "." + i);

				// 5:: GetObject
				Assert.IsTrue (r.Read (), "go#z-1" + "." + i);
				Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, "go#z-2" + "." + i);

				// 6:: m:Items(GetObject)
				Assert.IsTrue (r.Read (), "smz#1" + "." + i);
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "smz#2" + "." + i);
				Assert.AreEqual (XamlLanguage.Items, r.Member, "smz#3" + "." + i);

				for (int j = 0; j < 2; j++) {
					// 7:: t:SimpleType
					Assert.IsTrue (r.Read (), "soi#x-1" + "." + i + "-" + j);
					Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "soi#x-2" + "." + i + "-" + j);
					Assert.AreEqual (xt, r.Type, "soi#z-3" + "." + i + "-" + j);

					// 7:: /t:SimpleType
					Assert.IsTrue (r.Read (), "eoi#x-1" + "." + i + "-" + j);
					Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eoi#x-2" + "." + i + "-" + j);
				}

				// 6:: /m:Items(GetObject)
				Assert.IsTrue (r.Read (), "emz#x-1" + "." + i);
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "emz#x-2" + "." + i);

				// 5:: /GetObject
				Assert.IsTrue (r.Read (), "eo#z-1" + "." + i);
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#z-2" + "." + i);

				// 4:: /m:Items(ContentProperty)
				Assert.IsTrue (r.Read (), "em#x1" + "." + i);
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#x2" + "." + i);

				// 4-2:: m:NonContentItems
				Assert.IsTrue (r.Read (), "smv#1" + "." + i);
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "smv#2" + "." + i);
				Assert.AreEqual (xt.GetMember ("NonContentItems"), r.Member, "smv#3" + "." + i);

				// 5-2:: GetObject
				Assert.IsTrue (r.Read (), "go#z-1" + "." + i);
				Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, "go#v-2" + "." + i);

				// 6-2:: m:Items
				Assert.IsTrue (r.Read (), "smw#1" + "." + i);
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "smw#2" + "." + i);
				Assert.AreEqual (XamlLanguage.Items, r.Member, "smw#3" + "." + i);

				for (int j = 0; j < 2; j++) {
					// 7-2:: t:SimpleType
					Assert.IsTrue (r.Read (), "soi2#x-1" + "." + i + "-" + j);
					Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "soi2#x-2" + "." + i + "-" + j);
					Assert.AreEqual (xt, r.Type, "soi2#z-3" + "." + i + "-" + j);

					// 7-2:: /t:SimpleType
//.........这里部分代码省略.........
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:101,代码来源:XamlReaderTestBase.cs

示例13: Read_DirectDictionaryContainer2

		protected void Read_DirectDictionaryContainer2 (XamlReader r)
		{
			ReadNamespace (r, String.Empty, "http://www.domain.com/path", "ns#1");
			ReadNamespace (r, "x", XamlLanguage.Xaml2006Namespace, "ns#2");

			// t:DirectDictionaryContainer
			Assert.IsTrue (r.Read (), "so#1-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType (typeof (SecondTest.ResourcesDict2), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase (r);

			// m:Items
			Assert.IsTrue (r.Read (), "sm1#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm1#2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "sm1#3");

			xt = r.SchemaContext.GetXamlType (typeof (SecondTest.TestObject2));
			for (int i = 0; i < 2; i++) {
				// t:TestObject
				Assert.IsTrue (r.Read (), "so#x-1." + i);
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#x-2." + i);
				Assert.AreEqual (xt, r.Type, "so#x-3." + i);

				// m:Key
				Assert.IsTrue (r.Read (), "sm#y1");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#y2");
				Assert.AreEqual (XamlLanguage.Key, r.Member, "sm#y3");

				// value
				Assert.IsTrue (r.Read (), "v#y-1");
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#y-2");
				Assert.AreEqual (i == 0 ? "1" : "two", r.Value, "v#y-3");

				// /m:Key
				Assert.IsTrue (r.Read (), "em#y-1");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#y-2");

				// m:TestProperty
				Assert.IsTrue (r.Read (), "sm#x1");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#x2");
				Assert.AreEqual (xt.GetMember ("TestProperty"), r.Member, "sm#x3");

				// x:Value
				Assert.IsTrue (r.Read (), "v#x-1");
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#x-2");
				Assert.AreEqual (i == 0 ? "1" : "two", r.Value, "v#x-3");

				// /m:TestProperty
				Assert.IsTrue (r.Read (), "em#x-1");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#x-2");

				// /t:TestObject
				Assert.IsTrue (r.Read (), "eo#x-1");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#x-2");
			}

			// /m:Items
			Assert.IsTrue (r.Read (), "em#1-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#1-2");

			// /t:DirectDictionaryContainer
			Assert.IsTrue (r.Read (), "eo#1-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#1-2");

			Assert.IsFalse (r.Read (), "end");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:69,代码来源:XamlReaderTestBase.cs

示例14: Read_DirectDictionaryContainer

		protected void Read_DirectDictionaryContainer (XamlReader r)
		{
			var assns1 = "clr-namespace:MonoTests.Portable.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;
			ReadNamespace (r, String.Empty, assns1, "ns#1");
			ReadNamespace (r, "x", XamlLanguage.Xaml2006Namespace, "ns#2");

			// t:DirectDictionaryContainer
			Assert.IsTrue (r.Read (), "so#1-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType (typeof (DirectDictionaryContainer), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase (r);

			// m:Items
			Assert.IsTrue (r.Read (), "sm1#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm1#2");
			Assert.AreEqual (xt.GetMember ("Items"), r.Member, "sm1#3");

			// GetObject
			Assert.IsTrue (r.Read (), "go#1");
			Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, "go#2");

			// m:Items(GetObject)
			Assert.IsTrue (r.Read (), "sm2#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm2#2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "sm2#3");

			xt = r.SchemaContext.GetXamlType (typeof (int));
			for (int i = 0; i < 3; i++) {
				// t:DirectDictionaryContent
				Assert.IsTrue (r.Read (), "so#x-1." + i);
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#x-2." + i);
				Assert.AreEqual (xt, r.Type, "so#x-3." + i);

				// m:Key
				Assert.IsTrue (r.Read (), "sm#y1");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#y2");
				Assert.AreEqual (XamlLanguage.Key, r.Member, "sm#y3");

				// x:Value
				Assert.IsTrue (r.Read (), "v#y-1");
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#y-2");
				Assert.AreEqual (((EnumValueType) i).ToString ().ToLower (), r.Value, "v#y-3");

				// /m:Key
				Assert.IsTrue (r.Read (), "em#y-1");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#y-2");

				// m:Value
				Assert.IsTrue (r.Read (), "sm#x1");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#x2");
				Assert.AreEqual (XamlLanguage.Initialization, r.Member, "sm#x3");

				// x:Value
				Assert.IsTrue (r.Read (), "v#x-1");
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#x-2");
				Assert.AreEqual ("" + (i + 2) * 10, r.Value, "v#x-3");

				// /m:Value
				Assert.IsTrue (r.Read (), "em#x-1");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#x-2");

				// /t:DirectDictionaryContent
				Assert.IsTrue (r.Read (), "eo#x-1");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#x-2");
			}

			// /m:Items(GetObject)
			Assert.IsTrue (r.Read (), "em#2-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#2-2");

			// /GetObject
			Assert.IsTrue (r.Read (), "ego#2-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "ego#2-2");

			// /m:Items
			Assert.IsTrue (r.Read (), "em#1-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#1-2");

			// /t:DirectDictionaryContainer
			Assert.IsTrue (r.Read (), "eo#1-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#1-2");

			Assert.IsFalse (r.Read (), "end");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:87,代码来源:XamlReaderTestBase.cs

示例15: Read_DirectListContainer

		protected void Read_DirectListContainer (XamlReader r)
		{
			var assns1 = "clr-namespace:MonoTests.Portable.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;
			var assns2 = "clr-namespace:System.Collections.Generic;assembly=" + typeof (IList<>).Assembly.GetName ().Name;
			ReadNamespace (r, String.Empty, assns1, "ns#1");
			ReadNamespace (r, "scg", assns2, "ns#2");
			ReadNamespace (r, "x", XamlLanguage.Xaml2006Namespace, "ns#3");

			// t:DirectListContainer
			Assert.IsTrue (r.Read (), "so#1-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType (typeof (DirectListContainer), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase (r);

			// m:Items
			Assert.IsTrue (r.Read (), "sm1#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm1#2");
			Assert.AreEqual (xt.GetMember ("Items"), r.Member, "sm1#3");

			// GetObject
			Assert.IsTrue (r.Read (), "go#1");
			Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, "go#2");

			// m:Items(GetObject)
			Assert.IsTrue (r.Read (), "sm2#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm2#2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "sm2#3");

			xt = r.SchemaContext.GetXamlType (typeof (DirectListContent));
			for (int i = 0; i < 3; i++) {
				// t:DirectListContent
				Assert.IsTrue (r.Read (), "so#x-1." + i);
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#x-2." + i);
				Assert.AreEqual (xt, r.Type, "so#x-3." + i);

				// m:Value
				Assert.IsTrue (r.Read (), "sm#x1");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#x2");
				Assert.AreEqual (xt.GetMember ("Value"), r.Member, "sm#x3");

				// x:Value
				Assert.IsTrue (r.Read (), "v#x-1");
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#x-2");
				Assert.AreEqual ("Hello" + (i + 1), r.Value, "v#x-3");

				// /m:Value
				Assert.IsTrue (r.Read (), "em#x-1");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#x-2");

				// /t:DirectListContent
				Assert.IsTrue (r.Read (), "eo#x-1");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#x-2");
			}

			// /m:Items(GetObject)
			Assert.IsTrue (r.Read (), "em#2-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#2-2");

			// /GetObject
			Assert.IsTrue (r.Read (), "ego#2-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "ego#2-2");

			// /m:Items
			Assert.IsTrue (r.Read (), "em#1-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#1-2");

			// /t:DirectListContainer
			Assert.IsTrue (r.Read (), "eo#1-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#1-2");

			Assert.IsFalse (r.Read (), "end");
		}
开发者ID:Core2D,项目名称:Portable.Xaml,代码行数:75,代码来源:XamlReaderTestBase.cs


注:本文中的XamlReader.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。