本文整理汇总了C#中MemberPath.GetNodes方法的典型用法代码示例。如果您正苦于以下问题:C# MemberPath.GetNodes方法的具体用法?C# MemberPath.GetNodes怎么用?C# MemberPath.GetNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberPath
的用法示例。
在下文中一共展示了MemberPath.GetNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetNodes
public void TestGetNodes()
{
var memberPath = new MemberPath();
memberPath.Push(MemberSubs);
memberPath.Push(ListClassDesc, 2);
memberPath.Push(MemberMaps);
memberPath.Push(MapClassDesc, "toto");
memberPath.Push(MemberStruct);
memberPath.Push(MemberClass);
memberPath.Push(MemberValue);
var obj = new MyClass();
obj.Subs.Add(new MyClass());
obj.Subs.Add(new MyClass());
obj.Subs.Add(new MyClass());
obj.Subs[2].Maps["toto"] = new MyClass();
obj.Subs[2].Maps["toto"].Struct = new MyStruct { Class = new MyClass() };
var nodes = memberPath.GetNodes(obj).ToList();
Assert.AreEqual(8, nodes.Count);
Assert.AreEqual(obj, nodes[0].Object);
Assert.AreEqual(obj.Subs, nodes[1].Object);
Assert.AreEqual(obj.Subs[2], nodes[2].Object);
Assert.AreEqual(obj.Subs[2].Maps, nodes[3].Object);
Assert.AreEqual(obj.Subs[2].Maps["toto"], nodes[4].Object);
Assert.AreEqual(obj.Subs[2].Maps["toto"].Struct, nodes[5].Object);
Assert.AreEqual(obj.Subs[2].Maps["toto"].Struct.Class, nodes[6].Object);
Assert.AreEqual(obj.Subs[2].Maps["toto"].Struct.Class.Value, nodes[7].Object);
Assert.AreEqual(MemberSubs, nodes[0].Descriptor);
Assert.AreEqual(null, nodes[1].Descriptor);
Assert.AreEqual(MemberMaps, nodes[2].Descriptor);
Assert.AreEqual(null, nodes[3].Descriptor);
Assert.AreEqual(MemberStruct, nodes[4].Descriptor);
Assert.AreEqual(MemberClass, nodes[5].Descriptor);
Assert.AreEqual(MemberValue, nodes[6].Descriptor);
Assert.AreEqual(null, nodes[7].Descriptor);
}