本文整理汇总了C#中System.Compiler.Class.ExplicitImplementation方法的典型用法代码示例。如果您正苦于以下问题:C# Class.ExplicitImplementation方法的具体用法?C# Class.ExplicitImplementation怎么用?C# Class.ExplicitImplementation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Compiler.Class
的用法示例。
在下文中一共展示了Class.ExplicitImplementation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckForWrapperImplementationsForInheritedInterfaceImplementations
private void CheckForWrapperImplementationsForInheritedInterfaceImplementations(Class Class, Interface intf)
{
Contract.Requires(Class != null);
Contract.Requires(intf != null);
var members = intf.Members;
// if (members == null) return;
for (int i = 0; i < members.Count; i++)
{
var intfMethod = members[i] as Method;
if (intfMethod == null) continue;
if (Class.ExplicitImplementation(intfMethod) != null) continue;
if (Class.GetExactMatchingMethod(intfMethod) != null) continue;
var contractMethod = HelperMethods.GetContractMethod(intfMethod);
if (contractMethod == null) continue;
var contract = contractMethod.Contract;
if (contract == null) continue;
if (contract.RequiresCount + contract.EnsuresCount == 0) continue;
// find base implementing method
var baseMethod = FindInheritedMethod(Class.BaseClass, intfMethod);
if (baseMethod == null) continue;
var baseMethodImplementsInterfaceMethod = false;
if (baseMethod.ImplicitlyImplementedInterfaceMethods != null)
{
for (int j = 0; j < baseMethod.ImplicitlyImplementedInterfaceMethods.Count; j++)
{
if (baseMethod.ImplicitlyImplementedInterfaceMethods[j] == intfMethod)
{
baseMethodImplementsInterfaceMethod = true;
break;
}
}
}
if (baseMethodImplementsInterfaceMethod) continue;
if (this.runtimeCheckingLevel < 3 && contract.RequiresCount == 0) continue;
if (this.addInterfaceWrappersWhenNeeded)
{
AddInterfaceImplementationWrapper(Class, intfMethod, baseMethod);
}
else
{
this.HandleError(new Warning(1080,
string.Format(
"Type {0} implements {1} by inheriting {2} causing the interface contract to not be checked at runtime. Consider adding a wrapper method.",
Class.FullName, intfMethod.FullName, baseMethod.FullName),
default(SourceContext)));
}
}
}