Click or drag to resize

CodeFormatter Class

Provides source code syntax highlighting functionality.
Inheritance Hierarchy
SystemObject
  Ookii.FormatCCodeFormatter

Namespace:  Ookii.FormatC
Assembly:  Ookii.FormatC (in Ookii.FormatC.dll) Version: 2.1.0
Syntax
public class CodeFormatter

The CodeFormatter type exposes the following members.

Constructors
  NameDescription
Public methodCodeFormatter
Initializes a new instance of the CodeFormatter class.
Top
Properties
  NameDescription
Public propertyCssClass
Gets or sets the CSS class name to use on the <pre> element in the output HTML.
Public propertyFormattingInfo
Gets or sets the IFormattingInfo that provides information hot to format the source code.
Public propertyLineNumberFormat
Gets or sets the format string used to format the line numbers.
Public propertyLineNumberMode
Gets or sets the line number mode.
Public propertyTabSpaces
Gets or sets the number of spaces that a tab character should be replaced with.
Public propertyUsedFallbackFormatting
Gets a value indicating whether fallback formatting was used by the last call to FormatCode(String).
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodCode exampleFormatCode
Formats the specifies source code as HTML.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

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.

Examples

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"));
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also