Click or drag to resize

CodeWriter Class

Used to format code objects as text and write them into a string or a file.
Inheritance Hierarchy
SystemObject
  Nova.RenderingCodeWriter

Namespace:  Nova.Rendering
Assembly:  Nova.CodeDOM (in Nova.CodeDOM.dll) Version: 7.44.8391.13415
Syntax
C#
public class CodeWriter : IDisposable

The CodeWriter type exposes the following members.

Constructors
  NameDescription
Public methodCodeWriter(Boolean, Boolean)
Create a code writer that writes to a string.
Public methodCodeWriter(String, Encoding, Boolean, Boolean, Boolean)
Create a code writer that writes to a text file.
Top
Properties
  NameDescription
Public propertyAlignmentStateStack
Public propertyColumnNumber
The current column number (1 to N).
Public propertyIndentOffset
Get or set the current indent offset (0 to N).
Public propertyIsGenerated
True if the code being rendered is generated (such as a generated '.g.cs' file). Code cleanup settings will be ignored.
Public propertyLineNumber
The current line number (1 to N).
Public propertyNeedsNewLine
True if a newline is required before any other text, such as if a compiler directive was just emitted (used to force a newline before a terminating ';' on an expression with a compiler directive at the end).
Public propertyNewLine
Get or set the string used to create new lines (LF or CR/LF).
Top
Methods
  NameDescription
Public methodBeginAlignment
Begin the association of alignment information with a code object.
Public methodBeginIndentOnNewLine
Begin a section during which any newline should be indented an extra level.
Public methodBeginIndentOnNewLineRelativeToCurrentOffset
Begin a section during which any newline should be indented relative to the current offset.
Public methodBeginIndentOnNewLineRelativeToLastIndent
Begin a section during which any newline should be indented relative to the last indented offset.
Public methodBeginIndentOnNewLineRelativeToParentOffset
Begin a section during which any newline should be indented relative to the parent object offset.
Public methodBeginOutdentOnNewLine
Begin a section during which any newline should be outdented by a certain amount, or to a certain offset.
Public methodDispose
Dispose the object.
Public methodEndAlignment
End the association of alignment information with a code object.
Public methodEndIndentation
End a section during which any newline should be indented an extra level.
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 methodFlush
Flush any pending data.
Protected methodFlushPendingEOLComments
Public methodGetColumnWidth
Get the column width associated with the specified CodeObject.
Public methodGetColumnWidths
Get any column widths associated with the specified CodeObject.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetIndentOffset
Get the indentation offset of the specified code 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 methodSetParentOffset
Set the indent offset of the parent object.
Public methodToString
Convert all written data to a string.
(Overrides ObjectToString.)
Public methodWrite
Write the specified text.
Public methodWriteIdentifier
Write an identifier, prefixing with '@' if it happens to be a keyword.
Public methodWriteLine
Write optional text followed by a newline.
Public methodWriteLines
Write the specified number of newlines.
Public methodWriteList
Write a list of CodeObjects.
Public methodWriteName
Render a name, hiding any 'Attribute' suffix if it's an attribute name.
Public methodWritePendingEOLComment
Write a pending EOL comment, to be flushed later once it's known if anything follows it on the same line.
Top
Events
  NameDescription
Public eventAfterNewLine
This event is fired after a new line is created.
Top
Fields
  NameDescription
Protected field_alignmentStateStack
Protected field_columnNumber
Protected field_flushingEOLComments
Protected field_indentStateStack
Protected field_isEmptyLine
Protected field_isGenerated
Protected field_lastPoppedIndentState
Protected field_lineNumber
Protected field_pendingEOLComments
Protected field_textWriter
Public fieldEscapeUnicode
True if unicode characters should be escaped.
Public fieldInDocCommentContent
True if rendering documentation comment content.
Public fieldStatic memberKeywords
C# keywords.
Public fieldUseTabs
True if tabs should be used for indentation instead of spaces.
Top
Remarks
The main purpose of this class is to keep track of the indentation level, and to emit the spaces or tabs to create the indentation as the first text is written to each line. It also supports "pending comments" that are written in block style if not the last thing on the line. And, it keeps track of the current line number, and fires events when newlines are created.
See Also