public class CodeFormatter
Public Class CodeFormatter
public ref class CodeFormatter
type CodeFormatter = class end
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"));
CodeFormatter | Initializes a new instance of the CodeFormatter class. |
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. |
IncludePreElement | Gets or sets a value that indicates whether to emit the <pre> element in the output HTML. |
LineNumberCssClass | Gets or sets the CSS class used for <span> elements wrapping line numbers. |
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). |
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(String) | Formats the specified source code as HTML. |
FormatCode(String, TextWriter) | Formats the specified source code as HTML, writing the result to the specified TextWriter. |
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) |
DefaultCssClass | The default CSS class for the <pre> element wrapping the formatted output. The value is "code". |
DefaultLineNumberCssClass | The default CSS class for the <span> elements wrapping line numbers. The value is "lineNumber". |
DefaultLineNumberFormat | The default format string used for line numbers. The value is "{0,3}. ". |