private static bool MatchesClassAttribute(ClassInterceptAttribute attribute, MethodBase method) { var match = true; if (attribute.MulticastOptions > 0) { var bindingFlags = Enum.GetValues(typeof(MulticastOptions)) as MulticastOptions[]; foreach (var flag in bindingFlags.Where(flag => (flag & attribute.MulticastOptions) == flag)) { switch (attribute.MulticastOptions) { case MulticastOptions.Public: match = method.IsPublic; break; case MulticastOptions.Private: match = method.IsPrivate; break; case MulticastOptions.Protected: match = method.IsFamily; break; } } //foreach (var flag in bindingFlags) //{ // if ((flag & attribute.MulticastOptions) == flag) // { // switch (attribute.MulticastOptions) // { // case MulticastOptions.Public: // match = method.IsPublic; // break; // case MulticastOptions.Private: // match = method.IsPrivate; // break; // case MulticastOptions.Protected: // match = method.IsFamily; // break; // } // } //} } if (match && !String.IsNullOrEmpty(attribute.IncludePattern)) { match = Regex.IsMatch(method.Name, attribute.IncludePattern, RegexOptions.Singleline); } if (match && !String.IsNullOrEmpty(attribute.ExcludePattern)) { match = !Regex.IsMatch(method.Name, attribute.ExcludePattern, RegexOptions.Singleline); } return(match); }
private static bool MatchesClassAttribute(ClassInterceptAttribute attribute, MethodBase method) { var match = true; if (attribute.MulticastOptions > 0) { var bindingFlags = Enum.GetValues(typeof(MulticastOptions)) as MulticastOptions[]; foreach (var flag in bindingFlags.Where(flag => (flag & attribute.MulticastOptions) == flag)) { switch (attribute.MulticastOptions) { case MulticastOptions.Public: match = method.IsPublic; break; case MulticastOptions.Private: match = method.IsPrivate; break; case MulticastOptions.Protected: match = method.IsFamily; break; } } //foreach (var flag in bindingFlags) //{ // if ((flag & attribute.MulticastOptions) == flag) // { // switch (attribute.MulticastOptions) // { // case MulticastOptions.Public: // match = method.IsPublic; // break; // case MulticastOptions.Private: // match = method.IsPrivate; // break; // case MulticastOptions.Protected: // match = method.IsFamily; // break; // } // } //} } if (match && !String.IsNullOrEmpty(attribute.IncludePattern)) { match = Regex.IsMatch(method.Name, attribute.IncludePattern, RegexOptions.Singleline); } if (match && !String.IsNullOrEmpty(attribute.ExcludePattern)) { match = !Regex.IsMatch(method.Name, attribute.ExcludePattern, RegexOptions.Singleline); } return match; }