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


C# XamlReader类代码示例

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


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

示例1: Load

 public override object Load(XamlReader xamlReader, IServiceProvider context)
 {
     FuncFactory factory = FuncFactory.CreateFactory(xamlReader, context);
     IXamlNamespaceResolver nsResolver = context.GetService(typeof(IXamlNamespaceResolver)) as IXamlNamespaceResolver;
     if (nsResolver != null)
     {
         factory.ParentNamespaces = nsResolver.GetNamespacePrefixes().ToList();
     }
     return factory.GetFunc();
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:SerializableFuncDeferringLoader.cs

示例2: Load

 public override object Load(XamlReader xamlReader, IServiceProvider context)
 {
     IXamlObjectWriterFactory service = context.GetService(typeof(IXamlObjectWriterFactory)) as IXamlObjectWriterFactory;
     IProvideValueTarget target = context.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;
     Type propertyType = null;
     PropertyInfo targetProperty = target.TargetProperty as PropertyInfo;
     if (targetProperty != null)
     {
         propertyType = targetProperty.PropertyType;
     }
     object firstArgument = Activator.CreateInstance(typeof(FuncFactory).MakeGenericType(propertyType.GetGenericArguments()), new object[] { service, xamlReader });
     return Delegate.CreateDelegate(propertyType, firstArgument, firstArgument.GetType().GetMethod("Evaluate"));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:FuncDeferringLoader.cs

示例3: TemplateContent

 public TemplateContent(XamlReader xamlReader)
 {
     if (xamlReader == null)
         throw new ArgumentNullException("xamlReader");
     _SchemaContext = xamlReader.SchemaContext;
     _Cache = new MemoryStream();
     XamlXmlWriter writer = new XamlXmlWriter(_Cache, xamlReader.SchemaContext);
     //writer.WriteNamespace(xamlReader.Namespace);
     while (xamlReader.Read())
     {
         writer.WriteNode(xamlReader);
     }
     writer.Close();
 }
开发者ID:Kation,项目名称:WebPresentation,代码行数:14,代码来源:TemplateContent.cs

示例4: 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:imphasing,项目名称:mono,代码行数:47,代码来源:XamlReaderTestBase.cs

示例5: InsertNamespaces

 // We don't know what namespaces are actually used inside convertible values, so any namespaces
 // that were in the parent scope on load need to be regurgitated on save, unless the prefixes were
 // shadowed in the child scope.
 // This can potentially cause namespace bloat, but the alternative is emitting unloadable XAML.
 static XamlReader InsertNamespaces(XamlReader reader, IEnumerable<NamespaceDeclaration> parentNamespaces)
 {
     XamlNodeQueue namespaceNodes = new XamlNodeQueue(reader.SchemaContext);
     HashSet<string> childPrefixes = new HashSet<string>();
     while (reader.Read() && reader.NodeType == XamlNodeType.NamespaceDeclaration)
     {
         childPrefixes.Add(reader.Namespace.Prefix);
         namespaceNodes.Writer.WriteNode(reader);
     }
     foreach (NamespaceDeclaration parentNamespace in parentNamespaces)
     {
         if (!childPrefixes.Contains(parentNamespace.Prefix) &&
             !IsXmlNamespace(parentNamespace))
         {
             namespaceNodes.Writer.WriteNamespace(parentNamespace);
         }
     }
     if (!reader.IsEof)
     {
         namespaceNodes.Writer.WriteNode(reader);
     }
     return new ConcatenatingXamlReader(namespaceNodes.Reader, reader);
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:27,代码来源:SerializableFuncDeferringLoader.cs

示例6: Read_CustomMarkupExtension

		protected void Read_CustomMarkupExtension (XamlReader r)
		{
			r.Read (); // ns
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#1");
			r.Read (); // ns
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#1-2");
			r.Read ();
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#2-0");
			Assert.IsFalse (r.IsEof, "#1");
			var xt = r.Type;

			if (r is XamlXmlReader)
				ReadBase (r);

			r.Read ();
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#2-1");
			Assert.IsFalse (r.IsEof, "#2-2");
			Assert.AreEqual (xt.GetMember ("Bar"), r.Member, "#2-3");

			Assert.IsTrue (r.Read (), "#2-4");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#2-5");
			Assert.AreEqual ("v2", r.Value, "#2-6");

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

			r.Read ();
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#3-1");
			Assert.IsFalse (r.IsEof, "#3-2");
			Assert.AreEqual (xt.GetMember ("Baz"), r.Member, "#3-3");

			Assert.IsTrue (r.Read (), "#3-4");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#3-5");
			Assert.AreEqual ("v7", r.Value, "#3-6");

			Assert.IsTrue (r.Read (), "#3-7");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#3-8");
			
			r.Read ();
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#4-1");
			Assert.IsFalse (r.IsEof, "#4-2");
			Assert.AreEqual (xt.GetMember ("Foo"), r.Member, "#4-3");
			Assert.IsTrue (r.Read (), "#4-4");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#4-5");
			Assert.AreEqual ("x:Int32", r.Value, "#4-6");

			Assert.IsTrue (r.Read (), "#4-7");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#4-8");

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

			Assert.IsFalse (r.Read (), "#6");
		}
开发者ID:imphasing,项目名称:mono,代码行数:54,代码来源:XamlReaderTestBase.cs

示例7: Read_ArrayOrArrayExtensionOrMyArrayExtension

		protected void Read_ArrayOrArrayExtensionOrMyArrayExtension (XamlReader r, Action validateInstance, Type extType)
		{
			if (extType == typeof (MyArrayExtension)) {
				Assert.IsTrue (r.Read (), "#1");
				Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#2");
				Assert.IsNotNull (r.Namespace, "#3");
				Assert.AreEqual (String.Empty, r.Namespace.Prefix, "#3-2");
			}
			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 (extType, r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23");
			if (validateInstance != null)
				validateInstance ();

			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 ("Type"), r.Member, "#33");

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

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

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#62");
			Assert.AreEqual (xt.GetMember ("Items"), r.Member, "#63");

			Assert.IsTrue (r.Read (), "#71");
			Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, "#71-2");
			Assert.IsNull (r.Type, "#71-3");
			Assert.IsNull (r.Member, "#71-4");
			Assert.IsNull (r.Value, "#71-5");

			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 (), "#83");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#84"); // GetObject

			Assert.IsTrue (r.Read (), "#85");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#86"); // ArrayExtension.Items

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

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

示例8: Read_ListArray

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

			var defns = "clr-namespace:System.Collections.Generic;assembly=mscorlib";
			var defns2 = "clr-namespace:System;assembly=mscorlib";
			var defns3 = "clr-namespace:System.Xaml;assembly=System.Xaml";

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

			Assert.IsTrue (r.Read (), "ns#2-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#2-2");
			Assert.IsNotNull (r.Namespace, "ns#2-3");
			Assert.AreEqual ("s", r.Namespace.Prefix, "ns#2-3-2");
			Assert.AreEqual (defns2, r.Namespace.Namespace, "ns#2-3-3");

			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 (List<Array>), 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", "x:String"};
			for (int i = 0; i < 2; i++) {
				Assert.IsTrue (r.Read (), i + "#73");
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, i + "#73-2");
				Assert.AreEqual (XamlLanguage.Array, r.Type, i + "#73-3");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#74-2");
				Assert.AreEqual (XamlLanguage.Array.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.StartMember, r.NodeType, i + "#75-2");
				Assert.AreEqual (XamlLanguage.Array.GetMember ("Items"), r.Member, i + "#75-3");
				Assert.IsTrue (r.Read (), i + "#75-4");
				Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, i + "#75-5");
				Assert.IsTrue (r.Read (), i + "#75-7");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#75-8");
				Assert.AreEqual (XamlLanguage.Items, r.Member, i + "#75-9");

				for (int j = 0; j < 3; j++) {
					Assert.IsTrue (r.Read (), i + "#76-" + j);
					Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, i + "#76-2"+ "-" + j);
					Assert.IsTrue (r.Read (), i + "#76-3"+ "-" + j);
					Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#76-4"+ "-" + j);
					Assert.IsTrue (r.Read (), i + "#76-5"+ "-" + j);
					Assert.AreEqual (XamlNodeType.Value, r.NodeType, i + "#76-6"+ "-" + j);
					Assert.IsTrue (r.Read (), i + "#76-7"+ "-" + j);
					Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#76-8"+ "-" + j);
					Assert.IsTrue (r.Read (), i + "#76-9"+ "-" + j);
					Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#76-10"+ "-" + j);
				}

				Assert.IsTrue (r.Read (), i + "#77");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#77-2");

				Assert.IsTrue (r.Read (), i + "#78");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#78-2");

				Assert.IsTrue (r.Read (), i + "#79");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#79-2");

				Assert.IsTrue (r.Read (), i + "#80");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#80-2");
			}

			Assert.IsTrue (r.Read (), "#81");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#82"); // XamlLanguage.Items
			
//.........这里部分代码省略.........
开发者ID:imphasing,项目名称:mono,代码行数:101,代码来源:XamlReaderTestBase.cs

示例9: Read_NullOrNullExtension

		protected void Read_NullOrNullExtension (XamlReader r, Action validateInstance)
		{
			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 (NullExtension), r.SchemaContext), r.Type, "#23-2");
			if (validateInstance != null)
				validateInstance ();

			if (r is XamlXmlReader)
				ReadBase (r);

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

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

示例10: 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.System.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:imphasing,项目名称:mono,代码行数:42,代码来源:XamlReaderTestBase.cs

示例11: Read_DirectDictionaryContainer

		protected void Read_DirectDictionaryContainer (XamlReader r)
		{
			var assns1 = "clr-namespace:MonoTests.System.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:imphasing,项目名称:mono,代码行数:87,代码来源:XamlReaderTestBase.cs

示例12: Read_DirectListContainer

		protected void Read_DirectListContainer (XamlReader r)
		{
			var assns1 = "clr-namespace:MonoTests.System.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:imphasing,项目名称:mono,代码行数:75,代码来源:XamlReaderTestBase.cs

示例13: Read_NullableContainer

		protected void Read_NullableContainer (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.System.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;
			Assert.AreEqual (assns, r.Namespace.Namespace, "ns#1-5");

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

			if (r is XamlXmlReader)
				ReadBase (r);

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

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

			// /m:TestProp
			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:imphasing,项目名称:mono,代码行数:38,代码来源:XamlReaderTestBase.cs

示例14: ReadBase

		protected void ReadBase (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "sbase#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sbase#2");
			Assert.AreEqual (XamlLanguage.Base, r.Member, "sbase#3");

			Assert.IsTrue (r.Read (), "vbase#1");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "vbase#2");
			Assert.IsTrue (r.Value is string, "vbase#3");

			Assert.IsTrue (r.Read (), "ebase#1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "ebase#2");
		}
开发者ID:imphasing,项目名称:mono,代码行数:13,代码来源:XamlReaderTestBase.cs

示例15: ReadNamespace

		void ReadNamespace (XamlReader r, string prefix, string ns, string label)
		{
			Assert.IsTrue (r.Read (), label + "-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, label + "-2");
			Assert.IsNotNull (r.Namespace, label + "-3");
			Assert.AreEqual (prefix, r.Namespace.Prefix, label + "-4");
			Assert.AreEqual (ns, r.Namespace.Namespace, label + "-5");
		}
开发者ID:imphasing,项目名称:mono,代码行数:8,代码来源:XamlReaderTestBase.cs


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