Table of Contents

Class ReflectionEventSubscriber

Namespace
MongoDB.Driver.Core.Events
Assembly
MongoDB.Driver.Core.dll

Subscribes methods with a single argument to events of that single argument's type.

public sealed class ReflectionEventSubscriber : IEventSubscriber
Inheritance
ReflectionEventSubscriber
Implements
Inherited Members

Constructors

ReflectionEventSubscriber(object, string, BindingFlags)

Initializes a new instance of the ReflectionEventSubscriber class.

public ReflectionEventSubscriber(object instance, string methodName = "Handle", BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public)

Parameters

instance object

The instance.

methodName string

Name of the method to match against.

bindingFlags BindingFlags

The binding flags.

Methods

TryGetEventHandler<TEvent>(out Action<TEvent>)

Tries to get an event handler for an event of type TEvent.

public bool TryGetEventHandler<TEvent>(out Action<TEvent> handler)

Parameters

handler Action<TEvent>

The handler.

Returns

bool

true if this subscriber has provided an event handler; otherwise false.

Type Parameters

TEvent

The type of the event.