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

Fix eventing code examples

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Documentation
    • None

    Description

      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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: