本文整理汇总了C#中ITypeResolveContext.WithCurrentTypeDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeResolveContext.WithCurrentTypeDefinition方法的具体用法?C# ITypeResolveContext.WithCurrentTypeDefinition怎么用?C# ITypeResolveContext.WithCurrentTypeDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeResolveContext
的用法示例。
在下文中一共展示了ITypeResolveContext.WithCurrentTypeDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
public IMember Resolve(ITypeResolveContext context)
{
IType declaringType = typeReference.Resolve(context);
IMember interfaceMember = interfaceMemberReference.Resolve(context.WithCurrentTypeDefinition(declaringType.GetDefinition()));
if (interfaceMember == null)
return null;
var members = declaringType.GetMembers(
m => m.EntityType == interfaceMember.EntityType && m.IsExplicitInterfaceImplementation,
GetMemberOptions.IgnoreInheritedMembers);
return members.FirstOrDefault(m => m.ImplementedInterfaceMembers.Count == 1 && interfaceMember.Equals(m.ImplementedInterfaceMembers[0]));
}
示例2: Resolve
public IMember Resolve(ITypeResolveContext context)
{
IType declaringType = typeReference.Resolve(context);
IMember interfaceMember = interfaceMemberReference.Resolve(context.WithCurrentTypeDefinition(declaringType.GetDefinition()));
if (interfaceMember == null)
return null;
IEnumerable<IMember> members;
if (interfaceMember.SymbolKind == SymbolKind.Accessor) {
members = declaringType.GetAccessors(
m => m.IsExplicitInterfaceImplementation,
GetMemberOptions.IgnoreInheritedMembers);
} else {
members = declaringType.GetMembers(
m => m.SymbolKind == interfaceMember.SymbolKind && m.IsExplicitInterfaceImplementation,
GetMemberOptions.IgnoreInheritedMembers);
}
return members.FirstOrDefault(m => m.ImplementedInterfaceMembers.Count == 1 && interfaceMember.Equals(m.ImplementedInterfaceMembers[0]));
}