A
Anton Shepelev
Hello all,
I have a project with a lot of relatively small
classes, currently static, all of which have a sin-
gle public method, Init(), that registers the class
in a central module by subscribing for an event.
With such an architecture, adding a new class re-
quires also adding a line to the central module to
call its Init() method, so I have there:
public static void InitAll()
{ A.Init();
B.Init();
C.Init();
//...
}
Is it somehow possible to remove this coupling, so
that it would be enough just to add a new class to
the project for it get automatically subscribed? I
have thought of static constructors, but they are
called in a lazy manner, at the moment of first ref-
erence, and are therefore useless in my situation.
I have a project with a lot of relatively small
classes, currently static, all of which have a sin-
gle public method, Init(), that registers the class
in a central module by subscribing for an event.
With such an architecture, adding a new class re-
quires also adding a line to the central module to
call its Init() method, so I have there:
public static void InitAll()
{ A.Init();
B.Init();
C.Init();
//...
}
Is it somehow possible to remove this coupling, so
that it would be enough just to add a new class to
the project for it get automatically subscribed? I
have thought of static constructors, but they are
called in a lazy manner, at the moment of first ref-
erence, and are therefore useless in my situation.