Example #1
0
        /// <summary>
        /// Pops a reference off the evaluation stack and calls the getter of the given property on the object
        /// </summary>
        /// <param name="generator"></param>
        /// <param name="property">The property to get the value of</param>

        public static XsILGenerator GetProperty(this XsILGenerator generator, PropertyInfo property)
        {
            if (!property.CanRead)
            {
                throw new InvalidOperationException("Cannot read from this property");
            }

            var getMethod = property.GetGetMethod();

            return(generator.Call(getMethod));
        }
Example #2
0
        /// <summary>
        /// Pops a reference and a value off the evaluation stack and calls the setter of the given property on the object with the value
        /// </summary>
        /// <param name="generator"></param>
        /// <param name="property">The property to set</param>

        public static XsILGenerator SetProperty(this XsILGenerator generator, PropertyInfo property)
        {
            if (!property.CanWrite)
            {
                throw new InvalidOperationException("Cannot write to this property");
            }

            var setMethod = property.GetSetMethod();

            return(generator.Call(setMethod));
        }
Example #3
0
        /// <summary>
        /// Pops a reference to a delegate instance off the evaluation stack and calls the remover of the given event with it
        /// </summary>
        /// <param name="generator"></param>
        /// <param name="event">The event to remove the delegate instance from</param>

        public static XsILGenerator RemoveFromEvent(this XsILGenerator generator, EventInfo @event) => generator.Call(@event.GetRemoveMethod(true));
Example #4
0
        /// <summary>
        /// Pops a reference to a delegate instance off the evaluation stack and calls the adder of the given event with it
        /// </summary>
        /// <param name="generator"></param>
        /// <param name="event">The event to add the delegate instance to</param>

        public static XsILGenerator AddToEvent(this XsILGenerator generator, EventInfo @event) => generator.Call(@event.GetAddMethod(true));