static FieldInfo GetBackingField(MethodInfo method, ILPattern pattern) { var result = ILPattern.Match(method, pattern); if (!result.success) { throw new ArgumentException(); } object value; if (!result.TryGetData(FieldPattern.FieldKey, out value)) { throw new InvalidOperationException(); } return((FieldInfo)value); }
public static MatchContext Match(MethodBase method, ILPattern pattern) { if (method == null) { throw new ArgumentNullException("method"); } if (pattern == null) { throw new ArgumentNullException("pattern"); } var instructions = method.GetInstructions(); if (instructions.Count == 0) { throw new ArgumentException(); } var context = new MatchContext(instructions [0]); pattern.Match(context); return(context); }
static ILPattern Field(OpCode opcode) { return(new FieldPattern(ILPattern.OpCode(opcode))); }
public FieldPattern(ILPattern pattern) { this.pattern = pattern; }
public OptionalPattern(ILPattern optional) { this.pattern = optional; }
public static ILPattern Optional(ILPattern pattern) { return(new OptionalPattern(pattern)); }
public EitherPattern(ILPattern a, ILPattern b) { this.a = a; this.b = b; }
public static ILPattern Either(ILPattern a, ILPattern b) { return new EitherPattern (a, b); }
public static ILPattern Either(ILPattern a, ILPattern b) { return(new EitherPattern(a, b)); }
public SequencePattern(ILPattern [] patterns) { this.patterns = patterns; }
public static ILPattern Optional(ILPattern pattern) { return new OptionalPattern (pattern); }
public static MatchContext Match(MethodBase method, ILPattern pattern) { if (method == null) throw new ArgumentNullException ("method"); if (pattern == null) throw new ArgumentNullException ("pattern"); var instructions = method.GetInstructions (); if (instructions.Count == 0) throw new ArgumentException (); var context = new MatchContext (instructions [0]); pattern.Match (context); return context; }
static FieldInfo GetBackingField(MethodInfo method, ILPattern pattern) { var result = ILPattern.Match (method, pattern); if (!result.success) throw new ArgumentException (); object value; if (!result.TryGetData (FieldPattern.FieldKey, out value)) throw new InvalidOperationException (); return (FieldInfo) value; }