c# - Multiple registrations for the same decorator in a call chain -
i using simpleinjector dependency injection , i've discovered can register same decorator multiple times within single phone call chain , decorator applied per requested configuration. illustration can insert repositorytracedecorator first , lastly decorator of repository class:
container.registerdecorator(typeof(irepository<>), typeof(repositorytracedecorator<>)); container.registerdecorator(typeof(irepository<>), typeof(repositorydetectchangesdecorator<>)); container.registerdecorator(typeof(irepository<>), typeof(crossrepositorytransactionscopedecorator<>)); container.registerdecorator(typeof(irepository<>), typeof(repositorytracedecorator<>)); container.registerdecorator(typeof(irepository<>), typeof(repositoryexceptiondecorator<>));
is design , hence can depend on feature?
is design , hence can depend on feature?
as shown, can useful apply decorators multiple times in chain , changing behavior in future release breaking change. can ensure you can safely depend on , behavior won't change.
what might happen in future new diagnostics feature gets improved observe , warns having multiple identical decorators.
c# dependency-injection inversion-of-control simple-injector
No comments:
Post a Comment