예제 #1
0
        internal static MatchContext Match(MethodBase method, ILPattern pattern)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }

            var instructions = (IList <Instruction>)MethodBodyReader.GetInstructions(method).AsReadOnly();

            if (instructions.Count == 0)
            {
                throw new ArgumentException();
            }

            var context = new MatchContext(instructions[0]);

            pattern.Match(context);
            return(context);
        }
예제 #2
0
 public static List<Instruction> GetInstructions(MethodBase method)
 {
     var reader = new MethodBodyReader(method);
     reader.ReadInstructions();
     return reader._instructions;
 }