Class SourceFormatter
Base implementation of source code formatting. This allows for control of formatted output from CodeFactory.
Implements
Inherited Members
Namespace: CodeFactory
Assembly: CodeFactory.dll
Syntax
public class SourceFormatter : ISourceFormatter
Constructors
SourceFormatter(string)
Creates a new instance of the SourceFormatter
Declaration
public SourceFormatter(string indentStatement = "\t")
Parameters
Type | Name | Description |
---|---|---|
string | indentStatement | Optional parameter that allows you to set the target type of indent that will occur with each code statement. |
Methods
AppendCode(string)
Appends code to the end of the current line in the formatter.
Declaration
public void AppendCode(string code)
Parameters
Type | Name | Description |
---|---|---|
string | code | The code to append. |
AppendCodeBlock(int, IEnumerable<string>)
Appends a target indent level to a already formatted block of code.
Declaration
public void AppendCodeBlock(int indentLevel, IEnumerable<string> codeBlock)
Parameters
Type | Name | Description |
---|---|---|
int | indentLevel | The target indent level to be added to the existing code block. |
IEnumerable<string> | codeBlock | The block of code to append to. |
AppendCodeBlock(int, string)
Appends a target indent level to a already formatted block of code.
Declaration
public void AppendCodeBlock(int indentLevel, string codeBlock)
Parameters
Type | Name | Description |
---|---|---|
int | indentLevel | The target indent level to be added to the existing code block. |
string | codeBlock | The block of code to append to. |
AppendCodeLine(int)
Appends a new line of code to the formatter.
Declaration
public void AppendCodeLine(int indentLevel)
Parameters
Type | Name | Description |
---|---|---|
int | indentLevel | The number of indent levels to add to the source code. |
AppendCodeLine(int, string)
Appends a new line of code to the formatter.
Declaration
public void AppendCodeLine(int indentLevel, string code)
Parameters
Type | Name | Description |
---|---|---|
int | indentLevel | The number of indent levels to add to the source code. |
string | code | The code to add to the formatter. |
ResetFormatter()
Clears the formatter to be reused.
Declaration
public void ResetFormatter()
ReturnSource()
Returns the formatted source code.
Declaration
public string ReturnSource()
Returns
Type | Description |
---|---|
string | Formatted SourceCode. |