IsVisible() 공개 정적인 메소드

public static IsVisible ( IEventReference value, IVisibilityConfiguration visibility ) : bool
value IEventReference
visibility IVisibilityConfiguration
리턴 bool
예제 #1
0
        public static bool IsVisible(IEventReference value, IVisibilityConfiguration visibility)
        {
            if (Helper.IsVisible(value.DeclaringType, visibility))
            {
                switch (Helper.GetVisibility(value))
                {
                case MethodVisibility.Public:
                    return(visibility.Public);

                case MethodVisibility.Assembly:
                    return(visibility.Assembly);

                case MethodVisibility.FamilyOrAssembly:
                    return(visibility.FamilyOrAssembly);

                case MethodVisibility.Family:
                    return(visibility.Family);

                case MethodVisibility.Private:
                case MethodVisibility.PrivateScope:
                    return(visibility.Private);

                case MethodVisibility.FamilyAndAssembly:
                    return(visibility.FamilyAndAssembly);
                }

                throw new NotSupportedException();
            }

            return(false);
        }
예제 #2
0
        public static ICollection GetMethods(ITypeDeclaration value, IVisibilityConfiguration visibility)
        {
            ArrayList list = new ArrayList(0);

            IMethodDeclarationCollection methods = value.Methods;

            if (methods.Count > 0)
            {
                foreach (IMethodDeclaration methodDeclaration in methods)
                {
                    if ((visibility == null) || (Helper.IsVisible(methodDeclaration, visibility)))
                    {
                        list.Add(methodDeclaration);
                    }
                }

                foreach (IPropertyDeclaration propertyDeclaration in value.Properties)
                {
                    if (propertyDeclaration.SetMethod != null)
                    {
                        list.Remove(propertyDeclaration.SetMethod.Resolve());
                    }

                    if (propertyDeclaration.GetMethod != null)
                    {
                        list.Remove(propertyDeclaration.GetMethod.Resolve());
                    }
                }

                foreach (IEventDeclaration eventDeclaration in value.Events)
                {
                    if (eventDeclaration.AddMethod != null)
                    {
                        list.Remove(eventDeclaration.AddMethod.Resolve());
                    }

                    if (eventDeclaration.RemoveMethod != null)
                    {
                        list.Remove(eventDeclaration.RemoveMethod.Resolve());
                    }

                    if (eventDeclaration.InvokeMethod != null)
                    {
                        list.Remove(eventDeclaration.InvokeMethod.Resolve());
                    }
                }

                list.Sort();
            }

            return(list);
        }
예제 #3
0
        public static bool IsVisible(IType value, IVisibilityConfiguration visibility)
        {
            ITypeReference typeReference = value as ITypeReference;

            if (typeReference != null)
            {
                ITypeReference declaringType = typeReference.Owner as ITypeReference;
                if (declaringType != null)
                {
                    if (!Helper.IsVisible(declaringType, visibility))
                    {
                        return(false);
                    }
                }

                ITypeDeclaration typeDeclaration = typeReference.Resolve();
                if (typeDeclaration == null)
                {
                    return(true);
                }

                switch (typeDeclaration.Visibility)
                {
                case TypeVisibility.Public:
                case TypeVisibility.NestedPublic:
                    return(visibility.Public);

                case TypeVisibility.Private:
                case TypeVisibility.NestedPrivate:
                    return(visibility.Private);

                case TypeVisibility.NestedFamilyOrAssembly:
                    return(visibility.FamilyOrAssembly);

                case TypeVisibility.NestedFamily:
                    return(visibility.Family);

                case TypeVisibility.NestedFamilyAndAssembly:
                    return(visibility.FamilyAndAssembly);

                case TypeVisibility.NestedAssembly:
                    return(visibility.Assembly);

                default:
                    throw new NotImplementedException();
                }
            }

            throw new NotSupportedException();
        }
예제 #4
0
        public static ICollection GetInterfaces(ITypeDeclaration value, IVisibilityConfiguration visibility)
        {
            ArrayList list = new ArrayList(0);

            foreach (ITypeReference typeReference in GetInterfaces(value))
            {
                if (Helper.IsVisible(typeReference, visibility))
                {
                    list.Add(typeReference);
                }
            }

            list.Sort();
            return(list);
        }
예제 #5
0
        public static ICollection GetNestedTypes(ITypeDeclaration value, IVisibilityConfiguration visibility)
        {
            ArrayList list = new ArrayList(0);

            ITypeDeclarationCollection nestedTypes = value.NestedTypes;

            if (nestedTypes.Count > 0)
            {
                foreach (ITypeDeclaration nestedType in nestedTypes)
                {
                    if (Helper.IsVisible(nestedType, visibility))
                    {
                        list.Add(nestedType);
                    }
                }

                list.Sort();
            }

            return(list);
        }
예제 #6
0
        public static ICollection GetEvents(ITypeDeclaration value, IVisibilityConfiguration visibility)
        {
            ArrayList list = new ArrayList(0);

            IEventDeclarationCollection events = value.Events;

            if (events.Count > 0)
            {
                foreach (IEventDeclaration eventDeclaration in events)
                {
                    if ((visibility == null) || (Helper.IsVisible(eventDeclaration, visibility)))
                    {
                        list.Add(eventDeclaration);
                    }
                }

                list.Sort();
            }

            return(list);
        }
예제 #7
0
        public static ICollection GetProperties(ITypeDeclaration value, IVisibilityConfiguration visibility)
        {
            ArrayList list = new ArrayList(0);

            IPropertyDeclarationCollection properties = value.Properties;

            if (properties.Count > 0)
            {
                foreach (IPropertyDeclaration propertyDeclaration in properties)
                {
                    if ((visibility == null) || (Helper.IsVisible(propertyDeclaration, visibility)))
                    {
                        list.Add(propertyDeclaration);
                    }
                }

                list.Sort();
            }

            return(list);
        }
예제 #8
0
        public static ICollection GetFields(ITypeDeclaration value, IVisibilityConfiguration visibility)
        {
            ArrayList list = new ArrayList(0);

            IFieldDeclarationCollection fields = value.Fields;

            if (fields.Count > 0)
            {
                foreach (IFieldDeclaration fieldDeclaration in fields)
                {
                    if ((visibility == null) || (Helper.IsVisible(fieldDeclaration, visibility)))
                    {
                        list.Add(fieldDeclaration);
                    }
                }

                list.Sort();
            }

            return(list);
        }
예제 #9
0
        public static bool IsVisible(IFieldReference value, IVisibilityConfiguration visibility)
        {
            if (Helper.IsVisible(value.DeclaringType, visibility))
            {
                IFieldDeclaration fieldDeclaration = value.Resolve();
                if (fieldDeclaration == null)
                {
                    return(true);
                }

                switch (fieldDeclaration.Visibility)
                {
                case FieldVisibility.Public:
                    return(visibility.Public);

                case FieldVisibility.Assembly:
                    return(visibility.Assembly);

                case FieldVisibility.FamilyOrAssembly:
                    return(visibility.FamilyOrAssembly);

                case FieldVisibility.Family:
                    return(visibility.Family);

                case FieldVisibility.Private:
                    return(visibility.Private);

                case FieldVisibility.FamilyAndAssembly:
                    return(visibility.FamilyAndAssembly);

                case FieldVisibility.PrivateScope:
                    return(visibility.Private);
                }

                throw new NotSupportedException();
            }

            return(false);
        }