Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Implement an Autoplay Handler

, 18 Sep 2006
Implementing an Autoplay handler in C#.
autoplaydemo_demo.zip
Almdal.RegistryScript.dll
Almdal.SharedPipes.dll
AutoPlayDemo.exe
AutoPlayListener.dll
autoplaydemo_src.zip
AutoPlayDemo
Autoplay.ico
AutoPlayDemo.csproj.user
bin
Properties
Settings.settings
Resources
AutoPlayListener
Autoplay.ico
AutoPlayListener.snk
bin
Properties
Resources
Autoplay.ico
RegistryScript
Almdal.RegistryScript.snk
bin
Properties
SharedPipies
Almdal.SharedPipes.snk
bin
Properties
/********************************************************
 *	Author: Andrew Deren
 *	Date: July, 2004
 *	http://www.adersoftware.com
 * 
 *	StringTokenizer class. You can use this class in any way you want
 *	as long as this header remains in this file.
 * 
 *	Modified by T.Almdal
 *	To add addition tokens
 * 
 **********************************************************/

using System;
using System.Text;

namespace Almdal.RegistryScript {
	public enum TokenKind {
		Unknown,
		Word,
		Number,
		QuotedString,
        String,
		WhiteSpace,
		Symbol,
        StartKey,
        EndKey,
		Assignment,
		EOL,
		EOF
	}

	public class Token {
		int line;
		int column;
		string value;
		TokenKind kind;

		public Token(TokenKind kind, string value, int line, int column) {
			this.kind = kind;
			this.value = value;
			this.line = line;
			this.column = column;
		}

		public int Column {
			get { return this.column; }
		}

		public TokenKind Kind {
			get { return this.kind; }
		}

		public int Line {
			get { return this.line; }
		}

		public string Value {
			get { return this.value; }
		}

		public string ParsePosition {
			get {
				StringBuilder sb = new StringBuilder();
				sb.Append('(').Append(Line).Append(", ").Append(Column).Append(')');
				return sb.ToString();
			}
		}
        public override string ToString() {
            StringBuilder sb = new StringBuilder();
            sb.Append(base.ToString());
            sb.Append("[Kind: ").Append(Kind);
            sb.Append("; Value: ");
            switch (Kind) {
                case TokenKind.WhiteSpace:
                    sb.Append('"').Append(Value).Append('"');
                    break;
                case TokenKind.Unknown:
                case TokenKind.Symbol:
                    sb.Append('\'').Append(Value).Append('\'');
                    break;
                case TokenKind.EOL:
                    sb.Append("New Line");
                    break;
                default:
                    sb.Append(Value);
                    break;
            }
			sb.Append("; Position ").Append(ParsePosition).Append("]");
            return sb.ToString();
        }
	}

}

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)

Share

About the Author

Tim Almdal

Canada Canada
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 18 Sep 2006
Article Copyright 2006 by Tim Almdal
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid