Esempio n. 1
0
            public override void Match(MatchContext context)
            {
                pattern.Match(context);
                if (!context.success)
                {
                    return;
                }

                var match = GetLastMatchingInstruction(context);
                var field = (FieldInfo)match.Operand;

                context.AddData(FieldKey, field);
            }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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;
        }