Clone wiki

CodeCop / Bootstrapping


After you have configured which classes and methods you want CodeCop to intercept and created all your Interceptors, it's time to call the Intercept method of the Cop class.

This is the code that makes all the magic happen. You should place this call before all your main application code, e.g. if you are building a web application this is the code that normally goes into the Global.asax or the Startup.cs file.

The Intercept method of the Cop class has 2 overloads. Use the parameterless one if you want auto discovery of your Interceptors by the CodeCop runtime. (mandatory they have a default parameterless contructor).

  // The runtime will try to discover all your interceptors
  // Manually handle your interceptors to the runtime
  Cop.Intercept(new[] { new LoggingInterceptor(), new GuardNullInterceptor() });

  // or if you use an IoC container...