Class ASCII_Character_Display_Table
Provide read only access to a table of ASCII characters and text to display for selected special characters.
Inheritance
Namespace: WizardWrx
Assembly: WizardWrx.ASCIIInfo.dll
Syntax
public class ASCII_Character_Display_Table : object
Examples
The ASCII code for a space is 32. ASCIICharacterDisplayInfo[32], for C#, or ASCIICharacterDisplayInfo(32), for Visual Basic, returns the item for the space character.
Likewise, the ASCII code for a horizontal TAB character is 9. Hence, the C# expression ASCIICharacterDisplayInfo[9] evaluates to the information about the TAB character. Likewise, ASCIICharacterDisplayInfo(9) does the same thing in Visual Basic.
The following example comes from production code in the class library that motivated me to create this library.
ASCIICharacterDisplayInfo [ ] asciiCharTbl = ASCII_Character_Display_Table.GetTheSingleInstance ( ).AllASCIICharacters; StringBuilder sbTheBadChar = new StringBuilder ( ); sbTheBadChar.Append ( asciiCharTbl [ ( uint ) _chrBad ].DisplayText );
Obviously, more things go into the message before it is returned to the calling routine.
Properties
| Improve this Doc View SourceAllASCIICharacters
Gets the populated ASCIICharacterDisplayInfo array that is the sole public property of this class, which exists to ensure that exactly one instance of this table exists.
Declaration
public ASCIICharacterDisplayInfo[] AllASCIICharacters { get; }
Property Value
Type | Description |
---|---|
ASCIICharacterDisplayInfo[] |
Methods
| Improve this Doc View SourceGetTheSingleInstance()
Gets a reference to the single ASCII_Character_Display_Table instance.
Declaration
public static ASCII_Character_Display_Table GetTheSingleInstance()
Returns
Type | Description |
---|---|
ASCII_Character_Display_Table | The return value is a reference to the single instance of this class that is created in response to the first call to this method. Please see the remarks. |
Remarks
The example given under the help topic for this class shows you that you need not actually allocate storage for the instance, since what you really need is a copy of the ASCIICharacterDisplayInfo table, available through the read only AllASCIICharacters property, which can be assigned directly to an AllASCIICharacters array.
To preserve its independence, this class uses the archaic Singleton implementation, rather than inherit from the abstract base class in WizardWrx.DllServices2.dll, although I could certainly fix that by linking the source code into this assembly. Since that creates an even more awkward dependency, and I don't want to put an actual copy in this source tree, I'll leave it alone. After all, this class is not exactly a high traffic property.