CodeFormatter Class |
Namespace: Ookii.FormatC
The CodeFormatter type exposes the following members.
Name | Description | |
---|---|---|
CodeFormatter |
Initializes a new instance of the CodeFormatter class.
|
Name | Description | |
---|---|---|
CssClass |
Gets or sets the CSS class name to use on the <pre> element in the output HTML.
| |
FormattingInfo |
Gets or sets the IFormattingInfo that provides information hot to format the source code.
| |
LineNumberFormat |
Gets or sets the format string used to format the line numbers.
| |
LineNumberMode |
Gets or sets the line number mode.
| |
TabSpaces |
Gets or sets the number of spaces that a tab character should be replaced with.
| |
UsedFallbackFormatting |
Gets a value indicating whether fallback formatting was used by the last call to FormatCode(String).
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
FormatCode |
Formats the specifies source code as HTML.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
The CodeFormatter class will format source code based on the information provided by an implementation of the IFormattingInfo interface.
The result will be HTML source code that will display the formatted source code when combined with the appropriate style sheet.
The following code sample shows how to use the CodeFormatter class to format C# source code.
CodeFormatter formatter = new CodeFormatter(); formatter.FormattingInfo = new CSharpFormattingInfo(); string formattedHtml = formatter.FormatCode(System.IO.File.ReadAllText("MySourceFile.cs"));