SamSaffron/MiniProfiler — pull request #107 by danielcrenna (2013-01-24 17:38:39+00:00)
Title: Add ability to ignore sections of a profiled step or database profiling

TL;DR;
Here's a new extension method that lets me willingly ignore code blocks that profile SQL, or subsections of code blocks I'm already profiling.

Here's a pretend use case:
I have a profiled page that's showing multiple duplicate SQL warnings because I'm batching up user events and flushing them at the end of a request. I'm using SQLite or I've decided it's not worth bulk inserting these records. Forgetting the bad practice of blocking a request while I insert stuff in the database, I don't want a reminder on each profile load that I am using the same SQL to make multiple inserts because it might hide other real problems I don't know about. Or, maybe I just want to profile a step and ignore certain bits of it. For that I've added a simple `Ignore` extension that takes advantage of the internal IsActive flag to turn profiling on and off. I didn't have to make any invasive changes to the core, but I did have to add an internal getter for IsActive because I didn't want to reactivate prematurely if other extensions eventually use the same flag.

Usage:
```csharp
using(MiniProfiler.Current.Step("I want to profile some stuff but not other stuff"))
{
Thread.Sleep(2000); // Lalala stuff...

using (MiniProfiler.Current.Ignore())
{
// INSERT INTO...
// INSERT INTO...
// INSERT INTO...
// INSERT INTO...
UnitOfWork.Current.BulkCopy(stuff);
}
}
```