コード例 #1
0
ファイル: PatternApply.cs プロジェクト: Xtremrules/dot42
        private bool ApplyToMembers(TypeDefinition type, Pattern matcher, Action<MemberReference> action)
        {
            bool applied = false;

            foreach (var member in type.Methods)
            {
                if (matcher.MembersPublicOnly && !member.IsPublic)
                    continue;
                // DO PROCESS INDIVIDUAL GETTERS OR SETTERS.
                //if (member.IsGetter || member.IsSetter) continue; // [do not annotate individual setters]
                applied |= ApplyToMember(matcher, member, action);
            }
            foreach (var member in type.Fields)
            {
                if (matcher.MembersPublicOnly && !member.IsPublic)
                    continue;
                applied |= ApplyToMember(matcher, member, action);
            }
            foreach (var member in type.Properties)
            {
                if (matcher.MembersPublicOnly && (member.GetMethod == null || !member.GetMethod.IsPublic))
                    continue;
                applied |= ApplyToMember(matcher, member, action);
            }
            foreach (var member in type.Events)
            {
                if (matcher.MembersPublicOnly && (member.AddMethod == null || !member.AddMethod.IsPublic))
                    continue;
                applied |= ApplyToMember(matcher, member, action);
            }

            return applied;
        }
コード例 #2
0
ファイル: PatternApply.cs プロジェクト: Xtremrules/dot42
        private bool ApplyToMember(Pattern matcher, MemberReference member, Action<MemberReference> action)
        {
            if (matcher.MemberMatcher != null && !_matcher.MatchesWildcard(matcher.MemberMatcher, member.Name))
                return false;

            action(member);
            return true;
        }
コード例 #3
0
ファイル: PatternApply.cs プロジェクト: Xtremrules/dot42
        public bool Apply(Pattern pattern, TypeDefinition type, Action<MemberReference> action)
        {
            if (pattern == null)
                return false;

            bool applied = false;

            if (!_matcher.Matches(pattern, type))
                return false;

            if (pattern.MemberMatcher == null)
            {
                action(type);
                applied = true;
            }

            if (!pattern.ApplyToMembers && pattern.MemberMatcher == null)
                return applied;

            return ApplyToMembers(type, pattern, action) || applied;
        }
コード例 #4
0
ファイル: PatternInclude.cs プロジェクト: Xtremrules/dot42
        /// <summary>
        /// Default ctor
        /// </summary>
        public PatternInclude(string pattern, bool applyToMembers, bool isGlobal)
        {
            if (pattern == null)
                throw new ArgumentNullException("pattern");

            IsGlobal = isGlobal;
            
            _pattern = PatternParser.ParseMatcher(pattern, applyToMembers);
            if (IsEmpty)
                return;


            bool hasInclude = _pattern.Attributes.Any(a => a == "Dot42.Include");
            bool hasIncludeType = _pattern.Attributes.Any(a => a == "Dot42.IncludeType");

            if (hasIncludeType)
            {
                _pattern.ApplyToMembers = true;
            }
            else if(!hasInclude)
            {
                _pattern = null;
            }
        }