本文整理汇总了C#中ISymbol.GetWhitelistKey方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.GetWhitelistKey方法的具体用法?C# ISymbol.GetWhitelistKey怎么用?C# ISymbol.GetWhitelistKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISymbol
的用法示例。
在下文中一共展示了ISymbol.GetWhitelistKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsMemberWhitelisted
bool IsMemberWhitelisted(ISymbol memberSymbol, MyWhitelistTarget target)
{
while (true)
{
if (target == MyWhitelistTarget.Ingame && IsBlacklisted(memberSymbol))
{
return false;
}
var result = IsWhitelisted(memberSymbol.ContainingType, target);
if (result == TypeKeyQuantity.AllMembers)
{
return true;
}
MyWhitelistTarget allowedTarget;
if (m_whitelist.TryGetValue(memberSymbol.GetWhitelistKey(TypeKeyQuantity.ThisOnly), out allowedTarget) && allowedTarget.HasFlag(target))
{
return true;
}
if (memberSymbol.IsOverride)
{
memberSymbol = memberSymbol.GetOverriddenSymbol();
if (memberSymbol != null)
{
continue;
}
}
return false;
}
}
示例2: RegisterMember
void RegisterMember(MyWhitelistTarget target, ISymbol symbol, MemberInfo member)
{
if (!(symbol is IEventSymbol || symbol is IFieldSymbol || symbol is IPropertySymbol || symbol is IMethodSymbol))
{
throw new MyWhitelistException("Unsupported symbol type " + symbol);
}
var namespaceSymbol = symbol.ContainingNamespace;
if (namespaceSymbol != null && !namespaceSymbol.IsGlobalNamespace)
{
var namespaceKey = namespaceSymbol.GetWhitelistKey(TypeKeyQuantity.AllMembers);
MyWhitelistTarget existingTarget;
if (m_whitelist.TryGetValue(namespaceKey, out existingTarget) && existingTarget >= target)
{
throw new MyWhitelistException("The member " + member + " is covered by the " + namespaceKey + " rule");
}
}
var typeSymbol = symbol.ContainingType;
while (typeSymbol != null)
{
var typeKey = typeSymbol.GetWhitelistKey(TypeKeyQuantity.AllMembers);
MyWhitelistTarget existingTarget;
if (m_whitelist.TryGetValue(typeKey, out existingTarget) && existingTarget >= target)
{
throw new MyWhitelistException("The member " + member + " is covered by the " + typeKey + " rule");
}
// If there is no previous registration of the containing type, or the current registration
// is less restrictive than the one we're currently asking for, it needs to be updated.
// (this will only allow the reference of a type, but none of its members).
typeKey = typeSymbol.GetWhitelistKey(TypeKeyQuantity.ThisOnly);
if (!m_whitelist.TryGetValue(typeKey, out existingTarget) || existingTarget < target)
{
m_whitelist[typeKey] = target;
}
typeSymbol = typeSymbol.ContainingType;
}
var whitelistKey = symbol.GetWhitelistKey(TypeKeyQuantity.ThisOnly);
if (m_whitelist.ContainsKey(whitelistKey))
{
throw new MyWhitelistException("Duplicate registration of the whitelist key " + whitelistKey + " retrieved from " + member);
}
m_whitelist.Add(whitelistKey, target);
}
示例3: IsBlacklisted
bool IsBlacklisted(ISymbol symbol)
{
if (symbol.IsMemberSymbol())
{
if (m_ingameBlacklist.Contains(symbol.GetWhitelistKey(TypeKeyQuantity.ThisOnly)))
return true;
symbol = symbol.ContainingType;
}
var typeSymbol = symbol as ITypeSymbol;
while (typeSymbol != null)
{
if (m_ingameBlacklist.Contains(typeSymbol.GetWhitelistKey(TypeKeyQuantity.AllMembers)))
return true;
typeSymbol = typeSymbol.ContainingType;
}
return false;
}