D
dotnet007
Hi to All,
To jump into the deep instantly: Multicast event must not have return
value... by definition
Well, AssemblyResolve event has...
It returns the resolved assembly. But what if when you subscribe more than
one handler _independently_
to listen this event? That is why "Multicast event must not have return
value..."
Unfortunatelly localization (satellite assemblys) rely on AssemblyResolve.
So if you use localization, you can not attach your custom event handler ot
AssemblyResolve, because there is no way (by design of AssemblyResolve
event signature) to cooperate with each other.
As a last chance you think you go back 40 years to interrupt vector
chaining, and before you subscribe, you save the existing handler, and call
it in your new handler... But this is bad idea in three ways:
1) First of all it is impossible to get the existing handlers, because it is
an event, and not a "delegate type property" so we have a compiler
restriction (This is a good thing. the design error not in here, but the
event signature)
2) There is no guarantee that other subscribers will do the same if their
subscription is happen later in time... (after yours)
So the pretty += operator what are we using to subscribe is really a
randomly overriding = operator in this case.
What would be a good design?
No return value, and an bool Handled property in the ResolveEventArgs, and
the ResolvedAssembly property in ResolveEventArgs shoud do the work.
Missed I something?
thx for answers
To jump into the deep instantly: Multicast event must not have return
value... by definition
Well, AssemblyResolve event has...
It returns the resolved assembly. But what if when you subscribe more than
one handler _independently_
to listen this event? That is why "Multicast event must not have return
value..."
Unfortunatelly localization (satellite assemblys) rely on AssemblyResolve.
So if you use localization, you can not attach your custom event handler ot
AssemblyResolve, because there is no way (by design of AssemblyResolve
event signature) to cooperate with each other.
As a last chance you think you go back 40 years to interrupt vector
chaining, and before you subscribe, you save the existing handler, and call
it in your new handler... But this is bad idea in three ways:
1) First of all it is impossible to get the existing handlers, because it is
an event, and not a "delegate type property" so we have a compiler
restriction (This is a good thing. the design error not in here, but the
event signature)
2) There is no guarantee that other subscribers will do the same if their
subscription is happen later in time... (after yours)
So the pretty += operator what are we using to subscribe is really a
randomly overriding = operator in this case.
What would be a good design?
No return value, and an bool Handled property in the ResolveEventArgs, and
the ResolvedAssembly property in ResolveEventArgs shoud do the work.
Missed I something?
thx for answers