The main thing I would suggest to change is:
- to replace
AnotherDelegateMethod
andAnotherOneDelegateMethod
passing (and then calling from parent class) with corresponding virtual methods.
As for another things, that all depends on the logic your class is suppose to implement. Possibly, some more decoupling might be needed.
new AnotherRepository(ADelegateMethod). That's really a tough question how to do everything right -- more info about general logic would be needed, as different approaches possible:
- you can replace that also with virtual methods, like ADelegateMethod -- the same way as mentioned two above, but new AnotherRepository as
protected virtual ISomeRepositoryInterface CreateRepositoryInstance()
(for instance); you can use dependency injection into some outside classes which would use your handler to pass the the repository, the same, actually, as Tools or another repository (but, again, everything depends on the general logic);
one of the ways to customize your handler(s) is to make the basic class as Generic and to inherit the children with providing some concrete class, which logic is related exactly to the inheritor, but mostly used only in parent class.
- you can replace that also with virtual methods, like ADelegateMethod -- the same way as mentioned two above, but new AnotherRepository as
About events:
- I would recommend you to read something like this and generally get familiar with Rx (Reactive Extensions) -- they are modern and awesome (you can consider using them instead of events in many cases (if not in this handler class, then in some other situations)). (However, currently I can't see the situation when you really would need to use events in your class).
Also, as for @durilka's answer (however, that's really funny to trust him considering his nickname "liar" from Russian, he he): he mentioned correctly (before I got into that) about:
- to remove the nested class and replace with static constructor (if in base class). But that must be carefully rethinked (especially, if you really use multithreading widely).