Skip to content

Suggestion: utility methods to create interceptors or even intercepted objects #32

Description

@ndrwrbgs

To provide a simple interceptor like logging start/finish of all methods, users could use a utility method (lightweight) instead of being required to create a class (medium weight for a simple concern).

Example (typed from phone, so pseudo code):

IEquatable<string> sample = EqualityComparer<string>.Default;
// sample name stolen from Rx, if/when implementing spend more time naming
var wrapped = DelegateAsyncInterceptor
      .Intercept<IEquatable<string>>(
            target: sample,
            filter: invocation => true, // optional parameter
            beforeInvoke: async () => {}, // Log
            afterInvoke: async () => {}); // Log

Or at least

IEquatable<string> sample = EqualityComparer<string>.Default;
// sample name stolen from Rx, if/when implementing spend more time naming
var wrapped = DelegateAsyncInterceptor
      .Intercept<IEquatable<string>>(
            target: sample,
            interceptor:
                async (invocation, proceed) =>
                {
                     // TODO: logging
                     await proceed(invocation);
                });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions