RickStrahl / wwDotnetBridge

.NET Interop for Visual FoxPro made easy
http://west-wind.com/wwDotnetBridge.aspx
MIT License
74 stars 35 forks source link

Subscribe only to implemented events #26

Open cwollenhaupt opened 1 year ago

cwollenhaupt commented 1 year ago

Before subscribing to an event we check wether the VFP handler actually has a method to handle the event. Only if it does we subscribe to the event. This change lets us selectively implement only the events we are interested in, instead of having to implement all events.

Some .NET types implement lots of events and behave differently when an event is being subscribed. For instance, they might not collect and provide event data if there's no subscriber. Even though they shouldn't sometimes types expect a certain behavior from event handlers or alter the default behavior based on just the existence of a subscriber.

Two minor changes are included: Fixed typos (sorry!) and consistently use the SetError method instead of mixing direct assignments to the property with SetError calls. This makes it easier to subclass wwDotNetBridge when our application has its own logging scheme and we want to log all errors as they occur instead of checking after every call to wwDotNetBridge.

I've not recompiled wwDotNetBridge.DLL to avoid binary conflicts. For the same reason I've not updated the Examples directory with the updated PRG and DLL, nor did I remove the outdated PDB file.