TCPStateShell.zip contains full source
FILES:
TCPSTateShell.dll - no external dependencies
State classes implement a test of the State Pattern Also uses a
thread safe implementation of the Singleton Pattern. Supports context
sensitive help, Dynamic help, and Intellisense (TCPSTateShell.xml).
TCPStateAutoTester.dll - depends on TCPStateShell.dll and NUnit.Framework
Contains unit tests to assert that each state class implements the actions valid
for the state they represent and that calling them results in a transition to
the excpected state. There are also tests to assert that there are no
implmentations of actions that are invalid for each state. Supports context
sensitive help, Dynamic help, and Intellisense (TCPStateAutoTester.xml).
TCPStateTest.exe - depends on TCPStateAutoTester.dll
GUI test creates a TCPConnection object and 4 buttons to call its 4 methods and shows results.
Help integration into VS.NET was made simple with this article: http://www.codeproject.com/csharp/VSHelpIntegration.asp
Docs directory contains overview docs for the State and Singleton Patterns and "Impementing Singleton in C#" from Microsoft.
Comments: This pattern is very common especially in frameworks and tools. It promotes 'object thinking' because each of the state classes only implement the interfaces valid for the state that they represent.