Click here to Skip to main content
15,886,801 members
Articles / Code generation

Semi generated crawler

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
22 Jun 2012CPOL4 min read 21.6K   599   10  
Leverage Visual studio Web Test Framework for your crawling needs...
using System;
using System.ComponentModel;
using System.Globalization;
namespace LightWebTestFramework.Rules
{
	[LocalizableDescription("ConditionalRuleDescriptionContextParameterExistence"), LocalizableDisplayName("ConditionalRuleNameContextParameterExistence")]
	public class ContextParameterExistenceRule : ConditionalRule
	{
		private string m_contextParameterName;
		private bool m_checkForExistence;
		[LocalizableDescription("PropertyDescriptionContextParameterNameToFind"), LocalizableDisplayName("PropertyNameContextParameterName"), IsContextParameterName(false)]
		public string ContextParameterName
		{
			get
			{
				return this.m_contextParameterName;
			}
			set
			{
				this.m_contextParameterName = value;
			}
		}
		[LocalizableDescription("PropertyDescriptionCheckForParameterExistence"), LocalizableDisplayName("PropertyNameCheckForExistence"), DefaultValue(true)]
		public bool CheckForExistence
		{
			get
			{
				return this.m_checkForExistence;
			}
			set
			{
				this.m_checkForExistence = value;
			}
		}
		public override void CheckCondition(object sender, ConditionalEventArgs e)
		{
			if (this.m_checkForExistence && e.WebTest.Context.ContainsKey(this.m_contextParameterName))
			{
				e.IsMet = true;
				return;
			}
			if (!this.m_checkForExistence && !e.WebTest.Context.ContainsKey(this.m_contextParameterName))
			{
				e.IsMet = true;
				return;
			}
			e.IsMet = false;
		}
		public override string StringRepresentation()
		{
			if (this.m_checkForExistence)
			{
				return string.Format(CultureInfo.CurrentCulture, Resources.StringRepresentationCheckForParameterExistence, new object[]
				{
					this.m_contextParameterName
				});
			}
			return string.Format(CultureInfo.CurrentCulture, Resources.StringRepresentationCheckForParameterAbsence, new object[]
			{
				this.m_contextParameterName
			});
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Freelance
France France
I am currently the CTO of Metaco, we are leveraging the Bitcoin Blockchain for delivering financial services.

I also developed a tool to make IaaS on Azure more easy to use IaaS Management Studio.

If you want to contact me, go this way Smile | :)

Comments and Discussions