public void Raise(Type type, string eventName, params object[] args) { ProfilerInterceptor.GuardInternal(() => { RaiseEventBehavior.RaiseEventImpl(null, type.GetEvent(eventName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static), args); }); }
public void Raise(object instance, string eventName, params object[] args) { ProfilerInterceptor.GuardInternal(() => { RaiseEventBehavior.RaiseEventImpl(instance, MockingUtil.GetUnproxiedType(instance).GetEvent(eventName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance), args); }); }
/// <summary> /// Raises the specified event. If the event is not mocked and is declared on a C# or VB class /// and has the default implementation for add/remove, then that event can also be raised using this /// method, even with the profiler off. /// </summary> /// <typeparam name="T">Type of the object.</typeparam> /// <param name="obj">Target instance.</param> /// <param name="eventExpression">Event expression.</param> /// <param name="args">Delegate arguments.</param> public static void Raise <T>(this T obj, Action <T> eventExpression, params object[] args) { ProfilerInterceptor.GuardInternal(() => { var repo = MockingContext.CurrentRepository; var evt = repo.ParseAddHandlerAction(obj, eventExpression); RaiseEventBehavior.RaiseEventImpl(obj, evt, args); }); }
/// <summary> /// Raises the specified event. If the event is not mocked and is declared on a C# or VB class /// and has the default implementation for add/remove, then that event can also be raised using this /// method, even with the profiler off. The type on which the event is defined may need to be pre-intercepted /// using <see cref="Intercept"/> before calling Raise. /// </summary> /// <param name="eventExpression">Event expression</param> /// <param name="args">Delegate arguments</param> public static void Raise(Action eventExpression, params object[] args) { ProfilerInterceptor.GuardInternal(() => { object instance; var evt = MockingContext.CurrentRepository.ParseAddHandlerAction(eventExpression, out instance); RaiseEventBehavior.RaiseEventImpl(instance, evt, args); }); }
public void Raise(EventInfo eventInfo, params object[] args) { ProfilerInterceptor.GuardInternal(() => RaiseEventBehavior.RaiseEventImpl(null, eventInfo, args)); }