Game Development Reference
In-Depth Information
The real magic behind this tokenizer is from the regular expression capabilities of
.NET. There were a couple versions of this source code before regular expressions
were used, and this version is by far the shortest in length and the most maintainable.
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace ConsoleTokenizerLibrary
public sealed class ConsoleTokenizer
private readonly Dictionary<string, string> _parameters
= new Dictionary<string, string>();
private readonly List<string> _files = new List<string>();
public Dictionary<string, string> Parameters
get { return _parameters; }
public List<string> Files
get { return _files; }
A C# indexer operator has been provided to pull tokens from the parameter list.
This is merely an alternate way of obtaining these tokens with shorter code. Files
must still be accessed normally through the property.
public string this[string token]
get { return _parameters[token]; }
This constructor takes a single string and breaks it into an array of arguments
using a regular expression. The arguments array is then passed into the Tokenize()
Search Nedrilad ::

Custom Search