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


C# ISymbol.GetWhitelistKey方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:33,代码来源:MyScriptWhitelist.cs

示例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);
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:47,代码来源:MyScriptWhitelist.cs

示例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;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:18,代码来源:MyScriptWhitelist.cs


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