Beispiel #1
0
        public bool Test(PropertyKey prop, InheritMap map)
        {
            // method name matches type regex?
            if (!String.IsNullOrEmpty(type) && !Helper.CompareOptionalRegex(prop.TypeKey.Fullname, type))
            {
                return(false);
            }

            // method visibility matches
            if (MethodTester.CheckMemberVisibility(attrib, typeAttrib, GetPropertyMethodAttributes(prop.Property), prop.DeclaringType))
            {
                return(false);
            }

            // method's name matches
            if (nameRx != null && !nameRx.IsMatch(prop.Name))
            {
                return(false);
            }

            // method's name matches
            if (!string.IsNullOrEmpty(name) && !Helper.CompareOptionalRegex(prop.Name, name))
            {
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public bool Test(EventKey evt, InheritMap map)
        {
            // method name matches type regex?
            if (!String.IsNullOrEmpty(type) && !Helper.CompareOptionalRegex(evt.TypeKey.Fullname, type))
            {
                return(false);
            }

            if (MethodTester.CheckMemberVisibility(attrib, typeAttrib, GetEventMethodAttributes(evt.Event), evt.DeclaringType))
            {
                return(false);
            }

            // method's name matches
            if (nameRx != null && !nameRx.IsMatch(evt.Name))
            {
                return(false);
            }

            // method's name matches
            if (!string.IsNullOrEmpty(name) && !Helper.CompareOptionalRegex(evt.Name, name))
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        public bool Test(TypeKey type, InheritMap map)
        {
            if (!string.IsNullOrEmpty(attrib))
            {
                if (string.Equals(attrib, "public", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (!MethodTester.IsTypePublic(type.TypeDefinition))
                    {
                        return(false);
                    }
                }
                else
                {
                    throw new ApplicationException(string.Format("'{0}' is not valid for the 'attrib' value of the SkipType element. Only 'public' is supported by now.", attrib));
                }
            }

            // type's regex matches
            if (nameRx != null && !nameRx.IsMatch(type.Fullname))
            {
                return(false);
            }

            // type's name matches
            if (!string.IsNullOrEmpty(name) && !Helper.CompareOptionalRegex(type.Fullname, name))
            {
                return(false);
            }

            if (isSerializable.HasValue)
            {
                if (isSerializable != type.TypeDefinition.IsSerializable)
                {
                    return(false);
                }
            }

            if (isStatic.HasValue)
            {
                if (isStatic != (type.TypeDefinition.IsSealed && type.TypeDefinition.IsAbstract))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrEmpty(inherits))
            {
                if (!map.Inherits(type.TypeDefinition, inherits))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #4
0
        public bool Test(EventKey evt)
        {
            if (Helper.CompareOptionalRegex(evt.TypeKey.Fullname, type) && MethodTester.CheckMethodVisibility(attrib, evt.AddMethodAttributes))
            {
                if (name != null)
                {
                    return(Helper.CompareOptionalRegex(evt.Name, name));
                }
                else
                {
                    return(nameRx.IsMatch(evt.Name));
                }
            }

            return(false);
        }
Beispiel #5
0
        public bool Test(PropertyKey prop)
        {
            if (Helper.CompareOptionalRegex(prop.TypeKey.Fullname, type) && MethodTester.CheckMethodVisibility(attrib, prop.GetterMethodAttributes))
            {
                if (name != null)
                {
                    return(Helper.CompareOptionalRegex(prop.Name, name));
                }
                else
                {
                    return(nameRx.IsMatch(prop.Name));
                }
            }

            return(false);
        }
Beispiel #6
0
        public bool Test(PropertyKey prop, InheritMap map)
        {
            if (Helper.CompareOptionalRegex(prop.TypeKey.Fullname, type) && !MethodTester.CheckMemberVisibility(attrib, typeAttrib, prop.GetterMethodAttributes, prop.DeclaringType))
            {
                if (name != null)
                {
                    return(Helper.CompareOptionalRegex(prop.Name, name));
                }
                else
                {
                    return(nameRx.IsMatch(prop.Name));
                }
            }

            return(false);
        }
Beispiel #7
0
        public bool Test(EventKey evt, InheritMap map)
        {
            if (Helper.CompareOptionalRegex(evt.TypeKey.Fullname, type) && !MethodTester.CheckMemberVisibility(attrib, typeAttrib, evt.AddMethodAttributes, evt.DeclaringType))
            {
                if (name != null)
                {
                    return(Helper.CompareOptionalRegex(evt.Name, name));
                }
                else
                {
                    return(nameRx.IsMatch(evt.Name));
                }
            }

            return(false);
        }
Beispiel #8
0
        public bool Test(FieldKey field)
        {
            // It's not very clean to use CheckMethodVisibility() from MethodTester. But we don't want duplicate code either.
            if (Helper.CompareOptionalRegex(field.TypeKey.Fullname, type) && MethodTester.CheckMethodVisibility(attrib, (MethodAttributes)field.FieldAttributes))
            {
                if (name != null)
                {
                    return(Helper.CompareOptionalRegex(field.Name, name));
                }
                else
                {
                    return(nameRx.IsMatch(field.Name));
                }
            }

            return(false);
        }
Beispiel #9
0
        public bool Test(TypeKey type)
        {
            if (!string.IsNullOrEmpty(attrib))
            {
                if (string.Equals(attrib, "public", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (!MethodTester.IsTypePublic(type.TypeDefinition))
                    {
                        return(false);
                    }
                }
                else
                {
                    throw new ApplicationException(string.Format("'{0}' is not valid for the 'attrib' value of the SkipType element. Only 'public' is supported by now.", attrib));
                }
            }

            return(Helper.CompareOptionalRegex(type.Fullname, name));
        }
Beispiel #10
0
        public bool Test(FieldKey field, InheritMap map)
        {
            if (!string.IsNullOrEmpty(decorator))
            {
                var match = false;

                foreach (var typeField in field.TypeKey.TypeDefinition.Fields)
                {
                    if (typeField.Name != field.Name)
                    {
                        continue;
                    }

                    if (!typeField.HasCustomAttributes)
                    {
                        return(false);
                    }

                    foreach (var customAttr in typeField.CustomAttributes)
                    {
                        if (customAttr.AttributeType.FullName == decorator)
                        {
                            match = true;
                            break;
                        }
                    }
                }

                if (!match)
                {
                    return(false);
                }
            }

            if (!string.IsNullOrEmpty(type) && !Helper.CompareOptionalRegex(field.TypeKey.Fullname, type))
            {
                return(false);
            }

            // It's not very clean to use CheckMethodVisibility() from MethodTester. But we don't want duplicate code either.
            if (MethodTester.CheckMemberVisibility(attrib, typeAttrib, (MethodAttributes)field.FieldAttributes,
                                                   field.DeclaringType))
            {
                return(false);
            }

            if (nameRx != null && !nameRx.IsMatch(field.Name))
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(name) && !Helper.CompareOptionalRegex(field.Name, name))
            {
                return(false);
            }

            if (isStatic.HasValue)
            {
                bool fieldIsStatic = (field.FieldAttributes & FieldAttributes.Static) == FieldAttributes.Static;

                if (isStatic.Value != fieldIsStatic)
                {
                    return(false);
                }
            }

            if (isSerializable.HasValue)
            {
                if (isSerializable.Value && ((field.FieldAttributes & FieldAttributes.NotSerialized) ==
                                             FieldAttributes.NotSerialized))
                {
                    return(false);
                }

                bool fieldIsPublic        = (field.FieldAttributes & FieldAttributes.Public) == FieldAttributes.Public;
                bool parentIsSerializable = field.DeclaringType.IsSerializable;

                if (isSerializable != (fieldIsPublic && parentIsSerializable))
                {
                    return(false);
                }
            }

            // finally does method's type inherit?
            if (!string.IsNullOrEmpty(inherits))
            {
                if (!map.Inherits(field.DeclaringType, inherits))
                {
                    return(false);
                }
            }

            return(true);
        }