Class TSimpleTextNCFile
Simplest implementation of the output file. It is just wrapper around System.IO.StreamWriter that inherits TNCFile to be possible to manage it using TNCFilesManager. It has no any integration with the CLData Viewer so you will not see in live time any changes of this file in the CLData viewer. It will be shown there after the finish of whole postprocessing only. Use it only if you have some problems with TTextNCFile.
To use TSimpleTextNCFile class just create an instance of it and use WriteLine(string) or Write(string) methods to append some text to the file.
Also you can set the desired encoding TextEncoding of the output file.
Implements
Namespace: SprutCAMTech.SCPostprocessor
Assembly: SprutCAMTech.SCPostprocessor.dll
Syntax
public class TSimpleTextNCFile : TNCFile, INCBlockOwner
Constructors
TSimpleTextNCFile()
Initializes a new instance of TSimpleTextNCFile object and assigns TNCFilesManager.Singletone.DefaultNCFilesOwner
as an
Owner.
It assigns UTF-8 without BOM as a desired encoding of the output file (TextEncoding).
Declaration
public TSimpleTextNCFile()
TSimpleTextNCFile(INCFileOwner, Encoding)
Initializes a new instance of TSimpleTextNCFile object and assigns specified object as an Owner. It expects the encoding of the output text file as an input parameter.
Declaration
public TSimpleTextNCFile(INCFileOwner Owner, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
INCFileOwner | Owner | The object that is the owner of the output file formed by the postprocessor. Usually the owner is a postprocessor itself. |
System.Text.Encoding | encoding | Desired output file encoding. If it is null then default encoding of the System.IO.StreamWriter class will be used (UTF8 without BOM, TextEncoding). |
TSimpleTextNCFile(INCFileOwner)
Initializes a new instance of TSimpleTextNCFile object and assigns specified object as an Owner.
It assigns new UTF8Encoding(false)
(UTF-8 without BOM) as a desired encoding of the output file (TextEncoding).
Declaration
public TSimpleTextNCFile(INCFileOwner Owner)
Parameters
Type | Name | Description |
---|---|---|
INCFileOwner | Owner | The object that is the owner of the output file formed by the postprocessor. Usually the owner is a postprocessor itself. |
TSimpleTextNCFile(Encoding)
Initializes a new instance of TSimpleTextNCFile object and assigns TNCFilesManager.Singletone.DefaultNCFilesOwner
as an
Owner. It expects the encoding of the output text file as an input parameter (TextEncoding).
Declaration
public TSimpleTextNCFile(Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Encoding | encoding | Desired output file encoding. If it is null then default encoding of the System.IO.StreamWriter class will be used (UTF-8 without BOM). |
Properties
OutputFileName
The file name with a full path where this output file should be saved at the finish.
Declaration
public override string OutputFileName { get; set; }
Property Value
Type | Description |
---|---|
string |
Overrides
TextEncoding
Desired encoding of the output file. For example, you can use one of the following variants.
Encoding.GetEncoding("windows-1251")
- with specifying any standard textual name of the encoding.Encoding.UTF8
- UTF-8 with BOM (byte order mark bytes at the start of a file)Encoding.Unicode
- UTF-16 using the little endian byte order.Encoding.BigEndianUnicode
- UTF-16 using the big endian byte order.Encoding.Default
- The default encoding for this .NET implementation.new UTF8Encoding(false)
- UTF-8 without BOM will be used.null
- UTF-8 without BOM will be used.
You can assign TextEncoding not only at the initialization of new instance of TSimpleTextNCFile but at any time of postprocessing. It will be applied at the finish of whole postprocessing.
Declaration
public Encoding TextEncoding { get; set; }
Property Value
Type | Description |
---|---|
System.Text.Encoding |
Methods
Finalize()
Finalizes TSimpleTextNCFile instance and disposes system resources.
Declaration
protected override void Finalize()
Flush()
It should write the buffered in memory data for the output file to a hard drive (to a temporary files, not to the final destination). Usually you don't need to call it manually, the postprocessing system calls it as needed.
Declaration
public override void Flush()
Overrides
Output(string)
Writes the specified string with the line break (will be added automatically) to the end of the file.
Declaration
public void Output(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string you want to write. |
SaveToFile(string)
This method is called by the system automatically at the most final stage of the postprocessor's work. Here the content of the file should be written from a temporary storage (in memory or temporary file) to the destination file specified in the OutputFileName property.
After this saving the OnFinalizeNCFiles(TNCFilesManager) handler of the postprocessor is called where you can implement some additional actions on the output files.
Declaration
public override void SaveToFile(string fileName)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | The destination file path. |
Overrides
Write(string, INCLabel)
Attention! This feature doesn't supported by the TSimpleTextNCFile class. It will throw the EPostprocessorException exception.
To be possible to use random position file writing with INCLabel use TTextNCFile instead.
Declaration
public void Write(string s, INCLabel label)
Parameters
Type | Name | Description |
---|---|---|
string | s | |
INCLabel | label |
Exceptions
Type | Condition |
---|---|
EPostprocessorException |
Write(string)
Writes the specified string to the end of the file. No line break is added.
Declaration
public void Write(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string you want to write. |
WriteLine()
Writes the line break to the end of the file.
Declaration
public void WriteLine()
WriteLine(string, INCLabel)
Attention! This feature doesn't supported by the TSimpleTextNCFile class. It will throw the EPostprocessorException exception.
To be possible to use random position file writing with INCLabel use TTextNCFile instead.
Declaration
public void WriteLine(string s, INCLabel label)
Parameters
Type | Name | Description |
---|---|---|
string | s | |
INCLabel | label |
Exceptions
Type | Condition |
---|---|
EPostprocessorException |
WriteLine(string)
Writes the specified string with the line break (will be added automatically) to the end of the file.
Declaration
public void WriteLine(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string you want to write. |