本文整理汇总了C#中ContractFailureKind.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ContractFailureKind.ToString方法的具体用法?C# ContractFailureKind.ToString怎么用?C# ContractFailureKind.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContractFailureKind
的用法示例。
在下文中一共展示了ContractFailureKind.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateKindForBackwardCompatibility
private Literal TranslateKindForBackwardCompatibility(ContractFailureKind kind)
{
switch (kind)
{
case ContractFailureKind.Assert:
{
var field = this.contractNodes.ContractFailureKind.GetField(Identifier.For("Assert"));
Contract.Assume(field != null);
return field.DefaultValue;
}
case ContractFailureKind.Assume:
{
var field = this.contractNodes.ContractFailureKind.GetField(Identifier.For("Assume"));
Contract.Assume(field != null);
return field.DefaultValue;
}
case ContractFailureKind.Invariant:
{
var field = this.contractNodes.ContractFailureKind.GetField(Identifier.For("Invariant"));
Contract.Assume(field != null);
return field.DefaultValue;
}
case ContractFailureKind.Postcondition:
{
var field = this.contractNodes.ContractFailureKind.GetField(Identifier.For("Postcondition"));
Contract.Assume(field != null);
return field.DefaultValue;
}
case ContractFailureKind.PostconditionOnException:
{
var pe = this.contractNodes.ContractFailureKind.GetField(Identifier.For("PostconditionOnException"));
// hack
if (pe == null)
{ // Old CLR 4.0 beta
var field = this.contractNodes.ContractFailureKind.GetField(Identifier.For("Postcondition"));
Contract.Assume(field != null);
return field.DefaultValue;
}
return pe.DefaultValue;
}
case ContractFailureKind.Precondition:
{
var field = this.contractNodes.ContractFailureKind.GetField(Identifier.For("Precondition"));
Contract.Assume(field != null);
return field.DefaultValue;
}
default:
{
throw new ApplicationException(String.Format("Unexpected failure kind {0}", kind.ToString()));
}
}
}