本文整理汇总了C#中Foo.CheckConsistency方法的典型用法代码示例。如果您正苦于以下问题:C# Foo.CheckConsistency方法的具体用法?C# Foo.CheckConsistency怎么用?C# Foo.CheckConsistency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foo
的用法示例。
在下文中一共展示了Foo.CheckConsistency方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMutation
public void TestMutation()
{
// exclude members starting with an underscore
ObjectWalker walker = new ObjectWalker(delegate(MemberInfo member) { return !member.Name.StartsWith("_"); });
// all members
walker.IncludeNonPublicFields = true;
walker.IncludeNonPublicProperties = true;
walker.IncludePublicFields = true;
walker.IncludePublicProperties = true;
Foo foo = new Foo();
Foo foo2 = new Foo();
// in this test we change all the values of foo via the IObjectMemberContext
foreach (IObjectMemberContext context in walker.Walk(foo))
{
if (context.MemberType == typeof(bool))
context.MemberValue = false;
if (context.MemberType == typeof(string))
context.MemberValue = "goodbye";
if (context.MemberType == typeof(int))
context.MemberValue = 1;
if (context.MemberType == typeof(object))
context.MemberValue = foo2;
}
Assert.AreEqual(true, foo.CheckConsistency(false, "goodbye", 1, foo2));
}