Class BlockWriter
Provides useful functions for writing a block as a piece of LoliScript code.
Inheritance
Implements
Inherited Members
Namespace: RuriLib.LS
Assembly: RuriLib.dll
Syntax
public class BlockWriter : StringWriter, IDisposable
Constructors
| Improve this Doc View SourceBlockWriter(Type, Boolean, Boolean)
Creates a new BlockWriter for the given block type and with the given settings.
Declaration
public BlockWriter(Type blockType, bool indented = true, bool disabled = false)
Parameters
Type | Name | Description |
---|---|---|
System.Type | blockType | The Type of the block to write |
System.Boolean | indented | Whether the code can be indented on multiple lines for readability |
System.Boolean | disabled | Whether the block to write is disabled |
Methods
| Improve this Doc View SourceArrow()
Writes an Arrow (->) and a space.
Declaration
public BlockWriter Arrow()
Returns
Type | Description |
---|---|
BlockWriter | The BlockWriter itself |
Boolean(Boolean, String)
Writes a boolean with the syntax Name=Value and a space.
Declaration
public BlockWriter Boolean(bool boolean, string property)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | boolean | The boolean value to write |
System.String | property | The name of the property |
Returns
Type | Description |
---|---|
BlockWriter |
CheckDefault(Object, String)
Checks if a property has the default value.
Declaration
public bool CheckDefault(object value, string property)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value that needs to be checked |
System.String | property | The name of the property that contains that value |
Returns
Type | Description |
---|---|
System.Boolean | Whether the property has the default value or not |
Indent(Int32)
Writes a linebreak and a given number of spaces on the next line.
Declaration
public BlockWriter Indent(int spacing = 1)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | spacing | The amount of spacing to perform. A spacing of value 1 means two blank space characters, 2 means 4 etc. |
Returns
Type | Description |
---|---|
BlockWriter |
Integer(Int32, String)
Writes an integer value and a space.
Declaration
public BlockWriter Integer(int integer, string property = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | integer | The integer value to write |
System.String | property | The name of the property of the block. If the value is the default one, it will not be written. Do not set this parameter to always write the variable. |
Returns
Type | Description |
---|---|
BlockWriter | The BlockWriter itself |
Label(String)
Writes a block label as a # sign, the label name and a space.
Declaration
public BlockWriter Label(string label)
Parameters
Type | Name | Description |
---|---|---|
System.String | label | The label of the block |
Returns
Type | Description |
---|---|
BlockWriter | The BlockWriter itself |
Literal(String, String)
Writes a literal value (with escaped double-quotes) wrapped by double-quotes and a space.
Declaration
public BlockWriter Literal(string literal, string property = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | literal | The literal value to write |
System.String | property | The name of the property of the block. If the value is the default one, it will not be written. Do not set this parameter to always write the variable. |
Returns
Type | Description |
---|---|
BlockWriter | The BlockWriter itself |
Return()
Writes a linebreak.
Declaration
public BlockWriter Return()
Returns
Type | Description |
---|---|
BlockWriter |
Token(Object, String)
Writes any type of variable as a token (by calling its default ToString method) and a space.
Declaration
public BlockWriter Token(dynamic token, string property = "")
Parameters
Type | Name | Description |
---|---|---|
System.Object | token | The variable to write |
System.String | property | The name of the property of the block. If the value is the default one, it will not be written. Do not set this parameter to always write the variable. |
Returns
Type | Description |
---|---|
BlockWriter | The BlockWriter itself |