Пример #1
0
        public static bool IsAccessible(this Symbol symbol, TypeSymbol classCtx)
        {
            if (symbol.DeclaredAccessibility == Accessibility.Private)
            {
                return(symbol.ContainingType == classCtx);
            }
            else if (symbol.DeclaredAccessibility == Accessibility.Protected)
            {
                return(classCtx != null && (
                           symbol.ContainingType.IsEqualToOrDerivedFrom(classCtx) ||
                           classCtx.IsEqualToOrDerivedFrom(symbol.ContainingType)));
            }

            return(true);
        }
Пример #2
0
        static bool IsAccessible(MethodSymbol method, TypeSymbol classCtx)
        {
            if (method.DeclaredAccessibility == Accessibility.Private)
            {
                return(method.ContainingType == classCtx);
            }
            else if (method.DeclaredAccessibility == Accessibility.Protected)
            {
                return(classCtx != null && (
                           method.ContainingType.IsEqualToOrDerivedFrom(classCtx) ||
                           classCtx.IsEqualToOrDerivedFrom(method.ContainingType)));
            }

            return(true);
        }
Пример #3
0
        public static bool IsOfType(this TypeSymbol t, TypeSymbol oftype)
        {
            if (oftype != null)
            {
                HashSet <DiagnosticInfo> set = new HashSet <DiagnosticInfo>();
                if (t.IsEqualToOrDerivedFrom(oftype, true, ref set))
                {
                    return(true);
                }

                if (oftype.IsInterfaceType() && t.AllInterfaces.Contains(oftype))
                {
                    return(true);
                }
            }

            //
            return(false);
        }