Aspose.TeX的输入接口| .NET的Aspose.TeX
请参阅Aspose.TeX for .NET API参考有关I/O实施的正式定义。
输入目录的概念
由于tex语言的I/O元素只能处理文件名,因此Aspose.TeX for .NET将目录定义为名称和大部分数据之间的映射。大部分数据应该是文件,流,数组或其他任何数据。API允许我们分别指定输入和输出工作目录。它提供了常规 iInputworkingDirectory接口,用户可以为其自己的目的实现。它还提供了自己的实现,将在下面讨论。该接口定义了 getfile()方法,该方法返回数据流并确定文件的全名,同时以假设为不同的名称为第一个参数,实际上是映射密钥。
从磁盘文件系统获取文件输入
这就是我们的方式:
1// Getting file input from the disk file system
2
3// Create conversion options instance.
4TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
5// ...
6// Specify a file system working directory for the input.
7options.InputWorkingDirectory = new InputFileSystemDirectory(DataDir);此用例非常简单,因此无需重点关注它。
从zip档案中获取文件输入
我们还可以将输入文件放入zip存档中,并将其视为输入目录。在这种情况下,我们应该按以下方式进行:
1// Getting file input from a ZIP archive
2
3// Open the stream for the ZIP archive that will serve as the input working directory.
4using (Stream inZipStream = File.Open(Path.Combine(DataDir, "zip-in.zip"), FileMode.Open))
5{
6 // Create conversion options instance.
7 TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
8 // ...
9 // Specify a ZIP archive working directory for the input. You can also specify a path inside the archive.
10 options.InputWorkingDirectory = new InputZipDirectory(inZipStream, "in");首先,我们创建包含zip文件的流。然后,在创建转换选项后,我们将 InputWorkingDirectory选项设置为 InputzipDirectory类的实例。构造函数的第二个论点是存档内部的基本路径。如果我们希望整个存档成为输入目录,则应传递空字符串。
输入终端的概念
现在是时候记住还有终端输入了。至于这一点,Aspose.TeX for .NET定义了一般 iinputterminal接口,只有一个属性返回 TexTreader实现实例。提供的实现将在下面讨论。
从控制台获取终端输入
为此,我们需要将 终端素选项设置为 InputConsoleterminal类的实例。
1// Getting terminal input from the console
2
3// Create conversion options instance.
4TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
5// ...
6// Specify the console as the input terminal.
7options.TerminalIn = new InputConsoleTerminal(); // Default. Arbitrary assignment.但是,告诉您真相,这是该选项的默认值,因此没有真正的指定。由于这一事实,只要没有其他实施,本节就只有演示目的。
从理论上讲,如果我们具有具有可预测行为的交互式TEX文件(或脚本),我们可能希望实现输入终端的版本,该版本包含一个互补的脚本以响应Tex Engine的请求。有时间尝试您的手!