Skip to content

Conversation

@svick
Copy link
Contributor

@svick svick commented Jul 5, 2018

Fixes #6188.

Also made small formatting changes to the article with the larger sample.

The code in how-to-implement-custom-event-accessors.md seems to come from the larger sample in how-to-implement-interface-events.md, but probably wasn't updated when the larger sample was fixed. This way, it's ensured that both articles stay in sync from now on.

@svick svick requested a review from BillWagner as a code owner July 5, 2018 13:38
By providing your own accessors, you can specify whether the two events are represented by the same event in your class, or by different events. For example, if the events should be raised at different times according to the interface specifications, you can associate each event with a separate implementation in your class. In the following example, subscribers determine which `OnDraw` event they will receive by casting the shape reference to either an `IShape` or an `IDrawingObject`.

[!code-csharp[csProgGuideEvents#10](../../../csharp/programming-guide/events/codesnippet/CSharp/how-to-implement-interface-events_1.cs)]
[!code-csharp[csProgGuideEvents#10](../../../csharp/programming-guide/events/codesnippet/CSharp/how-to-implement-interface-events_1.cs#everything)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell based on VS Code preview, this way the #region lines won't be visible here.

@svick svick mentioned this pull request Jul 5, 2018
@svick svick force-pushed the event-accessor-sample branch from 952e495 to 12c40e6 Compare July 5, 2018 13:44
Copy link
Contributor

@rpetrusha rpetrusha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good, @svick. Thanks for doing this work. I'll merge your PR now.

@rpetrusha rpetrusha merged commit 7483fb8 into dotnet:master Jul 5, 2018
@svick svick deleted the event-accessor-sample branch July 5, 2018 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot lock on null object

2 participants