예제 #1
0
        private bool?ShouldTraceBasedOnClassLevelInfo(MethodDefinition definition)
        {
            var attributeInfo = GetTraceAttributeInfoForType(definition.DeclaringType);

            if (attributeInfo != null)
            {
                if (attributeInfo.IsNoTrace)
                {
                    return(false);
                }

                var targetVisibility = attributeInfo.TargetVisibility;
                var methodVisibility = VisibilityHelper.GetMethodVisibilityLevel(definition);
                return((int)targetVisibility >= (int)methodVisibility);
            }

            return(null);
        }
        internal override bool IsMatching(MethodDefinition methodDefinition)
        {
            if (base.IsMatching(methodDefinition))
            {
                var declaringType         = methodDefinition.DeclaringType;
                var typeVisibility        = VisibilityHelper.GetTypeVisibilityLevel(declaringType);
                var methodVisibilityLevel = VisibilityHelper.GetMethodVisibilityLevel(methodDefinition);

                //check type visibility
                if ((int)typeVisibility > (int)_targetClass)
                {
                    return(false);
                }

                //then method visibility will decide
                return((int)methodVisibilityLevel <= (int)_targetMethod);
            }
            return(false);
        }