I just implemented Clone from ICloneable and realized that the event subscriptions from my source instance also followed. Is there a good way to clear all those?
Currently I am using a couple of these loops for every event I have to clear everything.
foreach (var eventhandler in OnIdChanged.GetInvocationList())
{
OnIdChanged -= (ItemEventHandler) eventhandler;
}
foreach (var eventhandler in OnNameChanged.GetInvocationList())
{
...
This works fine but clutters the code a bit. Mostly worried to get event dangling.