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

Fix eventing code examples

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Scheduled
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Documentation
    • Labels:
      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.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dmitry.lukyanov Dmitry Lukyanov
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: