Skip to content

Instantly share code, notes, and snippets.

@atifaziz
Created July 16, 2009 11:30
Show Gist options
  • Save atifaziz/148371 to your computer and use it in GitHub Desktop.
Save atifaziz/148371 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Specialized;
using System.Xml;
using Elmah.Assertions;
static class Program
{
static void Main()
{
var config = new XmlDocument();
config.LoadXml(@"
<or>
<equal binding='Context.Request.ServerVariables[&apos;SERVER_NAME&apos;]' value='localhost' type='String' />
<equal binding='Context.Request.ServerVariables[&apos;SERVER_NAME&apos;]' value='10.10.2.101' type='String' />
<equal binding='Context.Request.ServerVariables[&apos;SERVER_NAME&apos;]' value='10.10.5.10' type='String' />
<and>
<regex binding='Context.Request.ServerVariables[&apos;HTTP_USER_AGENT&apos;]' pattern='Trident\/4\.0' />
<equal binding='Context.Request.ServerVariables[&apos;URL&apos;]' value='/MyApp/ScriptResource.axd' type='String' />
</and>
</or>");
var assertion = AssertionFactory.Create(config.DocumentElement);
var context = new
{
Context = new
{
Request = new
{
ServerVariables = new NameValueCollection {
{ "SERVER_NAME", "localhost" },
{ "HTTP_USER_AGENT", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)" },
{ "URL", "/MyApp/ScriptResource.axd" },
}
}
}
};
Console.WriteLine("Filter matched? " + assertion.Test(context));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment