예제 #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);
        }
예제 #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);
        }
예제 #3
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);
        }
예제 #4
0
        public bool Test(EventKey evt)
        {
            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);
        }
예제 #5
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.CheckMemberVisibility(attrib, typeAttrib, (MethodAttributes)field.FieldAttributes, field.DeclaringType))
            {
                if (name != null)
                {
                    return(Helper.CompareOptionalRegex(field.Name, name));
                }
                else
                {
                    return(nameRx.IsMatch(field.Name));
                }
            }

            return(false);
        }
예제 #6
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);
        }