Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3242

Fix eventing code examples

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Documentation
    • Labels:
      None

      This code example is invalid and won't be compiled https://mongodb.github.io/mongo-csharp-driver/2.10/reference/driver_core/events/.

      public class MyEventSubscriber : IEventSubscriber
      {
          public bool TryGetEventHandler<TEvent>(out Action<TEvent> handler)
          {
              if(typeof(TEvent)) == typeof(ConnectionPoolAddedConnectionEvent))
              {
                  handler = (Action<TEvent>)HandleConnectionPoolAddedConnectionEvent;
                  return true;
              }
              handler = null;
              return false;
          }
          private void HandleConnectionPoolAddedConnectionEvent(ConnectionPoolAddedConnectionEvent @event)
          {
              Console.WriteLine("Added a connection to the pool.");
          }
      }
      

      It should be fixed.

      Also, Handle methods should be public

            Assignee:
            Unassigned Unassigned
            Reporter:
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: