Created
July 16, 2009 11:30
-
-
Save atifaziz/148371 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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['SERVER_NAME']' value='localhost' type='String' /> | |
<equal binding='Context.Request.ServerVariables['SERVER_NAME']' value='10.10.2.101' type='String' /> | |
<equal binding='Context.Request.ServerVariables['SERVER_NAME']' value='10.10.5.10' type='String' /> | |
<and> | |
<regex binding='Context.Request.ServerVariables['HTTP_USER_AGENT']' pattern='Trident\/4\.0' /> | |
<equal binding='Context.Request.ServerVariables['URL']' 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