Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DelegateInterceptor; have LoggingInterceptor inherit from the new type #96

Closed
TheTribe opened this issue Aug 28, 2013 · 0 comments
Closed
Assignees
Milestone

Comments

@TheTribe
Copy link
Contributor

DoD: a new type, DelegateInterceptor, should exist. Its purpose is to allow the consumer to specify some, none, or all actions to take during the process of an interception. Similar to an event handling system, "handlers" for each major step should be used if provided; default handlers should be no-ops or equivalent logic should be used. In addition to allowing injectable actions to be taken during the process, an opt-out predicate should be injectable and should be used to determine whether interception should proceed using the delegated path, or if it should switch to plain-old-proxy mode. Once done, code like the following is possible:

var interceptor = new DelegateInterceptor(
  condition: invocation => invocation.Method.Name.StartsWith("Send"),
  beforeProceed: LogMemberAccess);

/*
** ...use the interceptor normally...
*/

where all use of types proxied with interceptor will have their method calls for all methods having names that start with "Send" logged according to the logic within LogMemberAccess.

Assumptions are:

  1. LoggingInterceptor should be able to inherit from this new type and reuse some of the code there.
  2. IoC registrations should still be possible wherein a singleton instance or factory is registered for an interceptor type, and component registrations can refer to the right interceptor registrations. This may already be the case with InterceptedBy(typeof(SomeInterceptor)) etc but hasn't been properly verified.
@ghost ghost assigned jbatte47 Aug 28, 2013
jbatte47 added a commit to jbatte47/code-patterns that referenced this issue Aug 30, 2013
* Added new DelegateInterceptor
* Changed LoggingInterceptor to inherit from DelegateInterceptor
* Updated test assertions to expect only one trace call for trapped error
  execution paths
* Updated ReSharper settings for "implicit scope closure"
TheTribe pushed a commit that referenced this issue Aug 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant