Click here to Skip to main content
15,897,968 members
Articles / Web Development / ASP.NET

ASP.NET C# Search Engine (Highlighting, JSON, jQuery & Silverlight)

Rate me:
Please Sign up or sign in to vote.
4.60/5 (38 votes)
8 Mar 2009CPOL10 min read 379.8K   13.2K   184  
More professional ASP.NET C# search with proper document summary, query highlighting and RIA display options
using System;
using System.Collections;
using Mono.GetOptions;

namespace GetOptTest
{
	class GetOptTestOptions : Options
	{
		[Option(3, "Just a testing Parameter", 'p')]
		public string[] param = new string[] { "Default value" };

		[Option("Just a boolean testing parameter", 't')]
		public bool turnItOn = false;

		private bool verboseOn = false;

		[Option("Be verbose", 'v')]
		public bool verbose
		{
			set 
			{ 
				verboseOn = value; 
				Console.WriteLine("verbose was set to : " + verboseOn);
			}
		}

		[Option(-1, "Execute a test routine", 's', null)]
		public WhatToDoNext simpleProcedure(int dids)
		{
			Console.WriteLine("Inside simpleProcedure({0})", dids);
			return WhatToDoNext.GoAhead;
		}

		[Option("Show usage syntax", 'u', "usage")]
		public override WhatToDoNext DoUsage()
		{
			base.DoUsage();
			return WhatToDoNext.GoAhead; 
		}

		public override WhatToDoNext DoHelp() // uses parent's OptionAttribute as is
		{
			base.DoHelp();
			return WhatToDoNext.GoAhead; 
		}

		public GetOptTestOptions()
		{
			this.ParsingMode = OptionsParsingMode.Both;
		}
	}

	/// <summary>
	/// Summary description for GetOptTester.
	/// </summary>
	class GetOptTester 
	{

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			Console.WriteLine("------------ Original 'args'");
			for(int i = 0; i < args.Length; i++)
				Console.WriteLine("args[{0}] = \"{1}\"",i,args[i]);
			Console.WriteLine("----------------------------------------");
			Console.WriteLine("------------ GetOptions Processing");
			GetOptTestOptions options = new GetOptTestOptions(); 
			options.ProcessArgs(args);
			Console.WriteLine("----------------------------------------");
			Console.WriteLine("------------ Results");
			if (options.param != null)
			{
				Console.WriteLine("Parameters supplied for 'param' were:");
				foreach (string Parameter in options.param)
					Console.WriteLine("\t" + Parameter);
			}
			for(int i = 0; i < options.RemainingArguments.Length; i++)
				Console.WriteLine("remaining args[{0}] = \"{1}\"",i,options.RemainingArguments[i]);
			Console.WriteLine("----------------------------------------");
		}
	}
}

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
Web Developer
Australia Australia
-- ooo ---
www.conceptdevelopment.net
conceptdev.blogspot.com
www.searcharoo.net
www.recipenow.net
www.racereplay.net
www.silverlightearth.com

Comments and Discussions