Extension - Html File Reader with Dynamic Token Replacement

[title]Html File Reader with Dynamic Token Replacement[/title]
[Ver 1.0 - 12/27/2011]
The classes defined in this project provide the ability to add dynamic content to static HTML data, including:

  • HTML files
  • HTML resource strings
  • HTML string constants

These classes will work equally well on the USBizi or EMX platform.

There is an abstract base class called HtmlReader, and two derived classes called HtmlDataReader and HtmlFileReader.

The base class provides functionality for replacing “token names” embedded into Html with their corresponding “token values” at runtime.

The token name/value pairs are passed to the constructor in a HashTable. The “token delimiter” is also passed to the constructor, but has a default value of ‘~’.

HtmlDataReader takes a byte array or string containing HTML data, and uses it as the source for the reader.

HtmlFileReader takes a file path, and internally creates a FileStream to use as the source for the reader.

The HtmlFileReader class was tested on a Panda II using an Http server that I wrote, running over a period of 18 hours, processing 216 Html “file” requests, and it experienced no failures and no memory leaks.

I’ve included several examples of how to use the readers, including the Html for two web pages that display dynamically updated network and device status information. The idea for these web pages came from @ Nicolas3’s excellent NetConfig code at http://code.tinyclr.com/project/308/netconfig-wiz5100-http-configuration-framework/

The example code contains references to other classes I’ve written that are part of my FEZConnect driver. Those classes are still under development, and will be released to the TinyCLR Code site soon.