Fix eventing code examples

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Gone away
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Documentation
    • None
    • 🔵 Done
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • 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
            Reporter:
            Dmitry Lukyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: