本文整理汇总了C#中XamlObjectReader类的典型用法代码示例。如果您正苦于以下问题:C# XamlObjectReader类的具体用法?C# XamlObjectReader怎么用?C# XamlObjectReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XamlObjectReader类属于命名空间,在下文中一共展示了XamlObjectReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadWriteListShouldRoundtrip
public void ReadWriteListShouldRoundtrip()
{
var sc = new XamlSchemaContext();
var list = new XamlNodeList(sc);
var reader = new XamlObjectReader(new TestClass4 { Foo = "foo", Bar = "bar" }, sc);
XamlServices.Transform(reader, list.Writer);
var writer = new XamlObjectWriter(sc);
var listReader = list.GetReader();
XamlServices.Transform(listReader, writer);
Assert.IsNotNull(writer.Result, "#1");
Assert.IsInstanceOf<TestClass4>(writer.Result, "#2");
Assert.AreEqual("foo", ((TestClass4)writer.Result).Foo, "#3");
Assert.AreEqual("bar", ((TestClass4)writer.Result).Bar, "#4");
// try reading a 2nd time, we should not get the same reader
writer = new XamlObjectWriter(sc);
var listReader2 = list.GetReader();
Assert.AreNotSame(listReader, listReader2, "#5");
XamlServices.Transform(listReader2, writer);
Assert.IsNotNull(writer.Result, "#6");
Assert.IsInstanceOf<TestClass4>(writer.Result, "#7");
Assert.AreEqual("foo", ((TestClass4)writer.Result).Foo, "#8");
Assert.AreEqual("bar", ((TestClass4)writer.Result).Bar, "#9");
}
示例2: ReadSubtree3
public void ReadSubtree3 ()
{
var xr = new XamlObjectReader (5);
xr.Read ();
xr.Read ();
var sr = xr.ReadSubtree ();
Assert.AreEqual (XamlNodeType.None, sr.NodeType, "#1-2");
Assert.AreEqual (XamlNodeType.StartObject, xr.NodeType, "#1-3");
Assert.IsTrue (sr.Read (), "#2");
Assert.AreEqual (XamlNodeType.StartObject, sr.NodeType, "#2-2");
Assert.AreEqual (XamlNodeType.StartObject, xr.NodeType, "#2-3");
Assert.IsTrue (sr.Read (), "#3");
Assert.AreEqual (XamlNodeType.StartMember, sr.NodeType, "#3-2");
Assert.AreEqual (XamlNodeType.StartMember, xr.NodeType, "#3-3");
Assert.IsTrue (sr.Read (), "#4");
Assert.AreEqual (XamlNodeType.Value, sr.NodeType, "#4-2");
Assert.AreEqual (XamlNodeType.Value, xr.NodeType, "#4-3");
Assert.IsTrue (sr.Read (), "#5");
Assert.AreEqual (XamlNodeType.EndMember, sr.NodeType, "#5-2");
Assert.AreEqual (XamlNodeType.EndMember, xr.NodeType, "#5-3");
Assert.IsTrue (sr.Read (), "#6");
Assert.AreEqual (XamlNodeType.EndObject, sr.NodeType, "#6-2");
Assert.AreEqual (XamlNodeType.EndObject, xr.NodeType, "#6-3");
Assert.IsFalse (sr.Read (), "#7");
Assert.AreEqual (XamlNodeType.None, xr.NodeType, "#7-2");
}
示例3: SetupReaderService
void SetupReaderService ()
{
Context = null;
var obj = new TestValueSerialized ();
var xr = new XamlObjectReader (obj);
while (!xr.IsEof && Context == null)
xr.Read ();
Assert.IsNotNull (Context, "SetupReader #1");
}
示例4: ReadSubtree1
public void ReadSubtree1 ()
{
var xr = new XamlObjectReader (5);
var sr = xr.ReadSubtree ();
Assert.AreEqual (XamlNodeType.None, sr.NodeType, "#1-2");
Assert.AreEqual (XamlNodeType.None, xr.NodeType, "#1-3");
Assert.IsTrue (sr.Read (), "#2");
Assert.AreEqual (XamlNodeType.None, sr.NodeType, "#2-2");
Assert.AreEqual (XamlNodeType.None, xr.NodeType, "#2-3");
Assert.IsFalse (sr.Read (), "#3");
Assert.AreEqual (XamlNodeType.NamespaceDeclaration, xr.NodeType, "#3-2");
}
示例5: GetService
public void GetService ()
{
var obj = new TestValueSerialized ();
var xr = new XamlObjectReader (obj);
while (!xr.IsEof)
xr.Read ();
Assert.IsNotNull (Context, "premise#1");
GetServiceCoreReader ();
Context = null;
var ctx = new XamlSchemaContext ();
var xw = new XamlObjectWriter (ctx);
var xt = ctx.GetXamlType (obj.GetType ());
xw.WriteStartObject (xt);
xw.WriteStartMember (XamlLanguage.Initialization);
xw.WriteValue ("v");
xw.WriteEndMember ();
xw.Close ();
Assert.IsNotNull (Provider, "premise#2"); // cannot get Context, it does not give IValueSerializerContext in the test.
GetServiceCoreWriter ();
}
示例6: Read_CommonXamlPrimitive
protected void Read_CommonXamlPrimitive (object obj)
{
var r = new XamlObjectReader (obj);
Read_CommonXamlType (r);
Read_Initialization (r, obj);
}
示例7: Read_AmbientPropertyContainer2
[Category (Categories.NotWorking)] // only member ordering difference, maybe.
public void Read_AmbientPropertyContainer2 ()
{
var obj = new SecondTest.ResourcesDict ();
var t1 = new SecondTest.TestObject ();
obj.Add ("TestDictItem", t1);
obj.Add ("okay", new SecondTest.ResourceExtension (t1));
var xr = new XamlObjectReader (obj);
Read_AmbientPropertyContainer (xr, true);
}
示例8: Read_CollectionContentPropertyX
public void Read_CollectionContentPropertyX ()
{
var obj = new CollectionContentPropertyX ();
var l = new List<object> ();
obj.ListOfItems.Add (l);
for (int i = 0; i < 4; i++)
l.Add (new SimpleClass ());
var xr = new XamlObjectReader (obj);
Read_CollectionContentPropertyX (xr, false);
}
示例9: Read_TypeConverterOnListMember
public void Read_TypeConverterOnListMember ()
{
var obj = new SecondTest.TypeOtherAssembly ();
obj.Values.AddRange (new uint? [] {1, 2, 3});
var xr = new XamlObjectReader (obj);
Read_TypeConverterOnListMember (xr);
}
示例10: Read_AbstractContainer
public void Read_AbstractContainer ()
{
var obj = new AbstractContainer () { Value2 = new DerivedObject () { Foo = "x" } };
var xr = new XamlObjectReader (obj);
while (!xr.IsEof)
xr.Read ();
}
示例11: are
[Test] // List contents are (sort of) treated as top-level too, so it is not serialized as IXmlSerializable(!)
public void Read_ListXmlSerializable ()
{
var obj = new List<XmlSerializable> ();
obj.Add (new XmlSerializable ("<root/>"));
var xr = new XamlObjectReader (obj);
Read_ListXmlSerializable (xr);
}
示例12: Read_ListWrapper2
public void Read_ListWrapper2 () // read-write list member.
{
var obj = new ListWrapper2 (new List<int> (new int [] {5, -3, 0}));
var r = new XamlObjectReader (obj);
Read_ListWrapper2 (r);
}
示例13: Read_ListWrapper
public void Read_ListWrapper ()
{
var obj = new ListWrapper (new List<int> (new int [] {5, -3, 0}));
var r = new XamlObjectReader (obj);
Read_ListWrapper (r);
}
示例14: ComplexPositionalParameters
public void ComplexPositionalParameters ()
{
var obj = new ComplexPositionalParameterWrapper () { Param = new ComplexPositionalParameterClass (new ComplexPositionalParameterValue () { Foo = "foo" })};
var r = new XamlObjectReader (obj);
ComplexPositionalParameters (r);
}
示例15: PositionalParameters2
public void PositionalParameters2 ()
{
var obj = new PositionalParametersWrapper ("foo", 5);
var r = new XamlObjectReader (obj);
PositionalParameters2 (r);
}