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


C# IScope.Create方法代码示例

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


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

示例1: FireErrors

 public static void FireErrors(IScope t)
 {
     t.Error("ErrA");
     using (var scope = t.Create("Nested"))
     {
         scope.Error("ErrB");
     }
     t.Error("ErrC");
 }
开发者ID:pocheptsov,项目名称:lokad-shared-libraries,代码行数:9,代码来源:ScopeTestHelper.cs

示例2: RunNesting

 public static void RunNesting(int nil, IScope scope)
 {
     scope.Write(RuleLevel.None, "None1");
     using (var child = scope.Create("Group1"))
     {
         child.Write(RuleLevel.Warn, "Warn1");
         using (var grand = child.Create("Group2"))
         {
             grand.Write(RuleLevel.None, "None2");
             grand.Error("Error1");
         }
         child.Write(RuleLevel.None, "None3");
     }
     scope.Write(RuleLevel.None, "None4");
 }
开发者ID:pocheptsov,项目名称:lokad-shared-libraries,代码行数:15,代码来源:ScopeTestHelper.cs

示例3: TestCollectionEquality

		bool TestCollectionEquality(IScope scope, IEnumerable expected, IEnumerable actual, int count1, int count2)
		{
			if (count1 != count2)
			{
				scope.Error("Expected ICollection count {0} was {1}", count1, count2);
				return false;
			}

			if (count1 == 0)
			{
				return true;
			}

			var e1 = expected.GetEnumerator();
			var e2 = actual.GetEnumerator();

			bool equals = true;

			for (int i = 0; i < count1; i++)
			{
				e1.MoveNext();
				e2.MoveNext();

				using (var child = scope.Create("[" + i + "]"))
				{
					bool result;
					if (TryReferenceCheck(child, e1.Current, e2.Current, out result))
					{
						equals |= result;
					}
					else
					{
						var t1 = e1.Current.GetType();
						var t2 = e2.Current.GetType();

						if (t1 != t2)
						{
							scope.Error("Expected '{0}' was '{1}'", t1, t2);
							equals = false;
						}
						else
						{
							var tester = _provider.GetEqualityTester(t1);

							if (!tester(child, t1, e1.Current, e2.Current))
							{
								equals = false;
							}
						}
					}
				}
			}
			return equals;
		}
开发者ID:pocheptsov,项目名称:lokad-shared-libraries,代码行数:54,代码来源:TestModelEqualityBuilder.cs

示例4: TestPropertyEquality

		bool TestPropertyEquality(IScope scope, object expected, object actual, PropertyInfo[] props)
		{

			bool equals = true;
			foreach (var fieldInfo in props)
			{
				var type = fieldInfo.PropertyType;

				var v1 = fieldInfo.GetValue(expected, null);
				var v2 = fieldInfo.GetValue(actual, null);

				using (var child = scope.Create(fieldInfo.Name))
				{
					var tester = _provider.GetEqualityTester(type);
					var localEquality = tester(child, type, v1, v2);
					if (!localEquality)
					{
						equals = false;
						//child.Error("Expected property '{0}' was '{1}'", v1, v2);
					}
				}
			}
			return equals;
		}
开发者ID:pocheptsov,项目名称:lokad-shared-libraries,代码行数:24,代码来源:TestModelEqualityBuilder.cs

示例5: TestFieldEquality

		bool TestFieldEquality(IScope scope, object one, object another, IEnumerable<FieldInfo> fields)
		{
			bool equals = true;
			foreach (var fieldInfo in fields)
			{
				var type = fieldInfo.FieldType;

				var v1 = fieldInfo.GetValue(one);
				var v2 = fieldInfo.GetValue(another);

				using (var child = scope.Create(fieldInfo.Name))
				{
					var equality = _provider.GetEqualityTester(type);
					var localEquality = equality(child, type, v1, v2);
					if (!localEquality)
					{
						equals = false;
						//child.Error("Expected field '{0}' was '{1}'", v1, v2);
					}
				}
			}
			return equals;
		}
开发者ID:pocheptsov,项目名称:lokad-shared-libraries,代码行数:23,代码来源:TestModelEqualityBuilder.cs


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