Interface IFileTypeManager
This is the main access point for file conversion operations.
The file type manager holds a prioritized list of file type definitions. The order of file type definitions is important, as it determines which file types take precedence over others in case multiple file type definitions could be used to process the same file. The most significant file type definition appears first in the list.
In implementations, the file type manager is often pre-configured with a set of file type definitions in the host application. However, the list can also be explicitly manipulated by calling AddFileTypeDefinition(IFileTypeDefinition), InsertFileTypeDefinition(Int32, IFileTypeDefinition) or RemoveFileTypeDefinition(IFileTypeDefinition). File type definitions can be instantiated from existing files or resources using the FileTypeDefinitionFactory.
Call one of the overloaded GetConverter...()
methods to use the file type definitions to
automatically detect file types and initialize a IMultiFileConverter to process the content.
Namespace: Sdl.FileTypeSupport.Framework.IntegrationApi
Assembly: Sdl.FileTypeSupport.Framework.Core.dll
Syntax
public interface IFileTypeManager
Remarks
Actual file type manager instances are often provided by the application that hosts the framework, in which case they are often pre-configured from some configuration (e.g. through the spring framework).
Properties
AutoLoadedFileTypes
Gets a list of filetypes which should be auto-loaded by the Host. This is used to indicate new file types in this particular version of the FileTypeManager
Declaration
List<string> AutoLoadedFileTypes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<System.String> |
ConfigurationVersionInformation
Provides information on the version of the configuration information that is used to instantiate the current instance of the IFileTypeManager. This can be used to determine whether the instance is working with the latest version of configuration information that the host application requires.
For instance, applications may transfer their file type manager configuration information from one system to another. By checking this property the application can determine the state of the configuration, and perform additional tasks to ensure the configuration is in the format that the application requires (e.g. deploy additional filters that have only been released in the latest version of the application).
Declaration
string ConfigurationVersionInformation { get; }
Property Value
Type | Description |
---|---|
System.String |
DefaultBilingualFileTypeDefinition
The file type definitions that should be used as the default bilingual file type, or null
if none.
Declaration
IFileTypeDefinition DefaultBilingualFileTypeDefinition { get; set; }
Property Value
Type | Description |
---|---|
IFileTypeDefinition |
Remarks
By default, this property returns the first file type definition in the list for which the IsBilingualDocumentFileType is true.
The default bilingual file type can be explicitly changed by setting this property to another file type definition in the list that is also a bilingual document file type.
Attempting to set this property to a file type definition that is not in the list will yield a FileTypeDefinitionNotFoundException.
Attempting to set this property to a file type definition that is not a bilingual document file type will yield a NotBilingualFileTypeException.
FileTypeDefinitionFactory
Provides access to the implementation used to instantiate file type definitions. Can be used to explicitly create a file type definition that can be added to the manager by calling AddFileTypeDefinition(IFileTypeDefinition) or InsertFileTypeDefinition(Int32, IFileTypeDefinition).
Declaration
IFileTypeDefinitionFactory FileTypeDefinitionFactory { get; }
Property Value
Type | Description |
---|---|
IFileTypeDefinitionFactory |
FileTypeDefinitions
The file type definitions that are currently known to this instance of the file type manager.
The order of the file type definitions defines their relative priority, with the most significant file type definition appearing first.
Declaration
IFileTypeDefinition[] FileTypeDefinitions { get; }
Property Value
Type | Description |
---|---|
IFileTypeDefinition[] |
SettingsBundle
The settings bundle containing the settings used by components of the
FileTypeManager. This property should be set before any operations
requiring the use of settings are invoked (for example, GetConverterToBilingual
implementations) or the operation may not work as expected.
This property can return null
if no settings bundle has been set.
Declaration
ISettingsBundle SettingsBundle { get; set; }
Property Value
Type | Description |
---|---|
ISettingsBundle |
Methods
AddFileTypeDefinition(IFileTypeDefinition)
Appends a file type definition to the collection.
Declaration
void AddFileTypeDefinition(IFileTypeDefinition fileTypeDefinition)
Parameters
Type | Name | Description |
---|---|---|
IFileTypeDefinition | fileTypeDefinition |
Remarks
The file type definition is added last in the list of known file type definitions.
BuildAdditionalGeneratorsInfo(IGeneratorInfo[])
Helper method to create additional generator information so that it can be used by filter component builders.
Declaration
IAdditionalGeneratorsInfo BuildAdditionalGeneratorsInfo(params IGeneratorInfo[] generators)
Parameters
Type | Name | Description |
---|---|---|
IGeneratorInfo[] | generators |
Returns
Type | Description |
---|---|
IAdditionalGeneratorsInfo |
BuildBilingualGenerator(IBilingualDocumentWriter)
Helper function to create a bilingual generator for a bilingual document writer, so that
it can be used with relevant overloads to GetConverter
.
Declaration
IBilingualDocumentGenerator BuildBilingualGenerator(IBilingualDocumentWriter bilingualWriter)
Parameters
Type | Name | Description |
---|---|---|
IBilingualDocumentWriter | bilingualWriter | a bilingual document writer, capable of serializing the bilingual content model |
Returns
Type | Description |
---|---|
IBilingualDocumentGenerator | a bilingual document generator instance where the bilingual writer is assigned to the Writer property. |
BuildBilingualGenerator(IFileTypeDefinition)
Helper function used by the file type manager implementation and other components that need to instantiate a bilingual generator for a specific file type.
Declaration
IBilingualDocumentGenerator BuildBilingualGenerator(IFileTypeDefinition filterDefinitionToUse)
Parameters
Type | Name | Description |
---|---|---|
IFileTypeDefinition | filterDefinitionToUse |
Returns
Type | Description |
---|---|
IBilingualDocumentGenerator |
BuildDefaultBilingualGenerator()
Helper function that constructs an instance of a generator for the default bilingual file format, if set.
Declaration
IBilingualDocumentGenerator BuildDefaultBilingualGenerator()
Returns
Type | Description |
---|---|
IBilingualDocumentGenerator |
|
See Also
BuildExtractor(String, CultureInfo, Codepage, INativeTextLocationMessageReporter)
Helper function used by the file type manager implementation and other components that need to create components that are normally used through the file converters objects.
Determines the best matching file type for the specified file according to the rules described in the documentation of GetConverter(String[], CultureInfo, Codepage, EventHandler<MessageEventArgs>) and returns an initialized file extractor that can be used to process the file.
Declaration
IFileExtractor BuildExtractor(string filePath, CultureInfo cultureInfo, Codepage suggestedCodepage, INativeTextLocationMessageReporter messageReporter)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | |
System.Globalization.CultureInfo | cultureInfo | Source CultureInfo of the file |
Codepage | suggestedCodepage | Suggested codepage of the file |
INativeTextLocationMessageReporter | messageReporter | (Optional) message reporter implementation that will be passed to file sniffers |
Returns
Type | Description |
---|---|
IFileExtractor |
Exceptions
Type | Condition |
---|---|
FileNotSupportedException | Thrown if none of the file type definitions can be used to process the file |
BuildExtractorNoSniffing(String, String, CultureInfo, Codepage, INativeTextLocationMessageReporter)
Builds a FileExtractor without sniffing - the FileType to use is defined by the fileTypeDefinitionId
Declaration
IFileExtractor BuildExtractorNoSniffing(string fileTypeDefinitionId, string filePath, CultureInfo suggestedSourceLanguage, Codepage suggestedCodepage, INativeTextLocationMessageReporter messageReporter)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileTypeDefinitionId | |
System.String | filePath | |
System.Globalization.CultureInfo | suggestedSourceLanguage | |
Codepage | suggestedCodepage | |
INativeTextLocationMessageReporter | messageReporter |
Returns
Type | Description |
---|---|
IFileExtractor |
BuildFileExtractor(IBilingualParser, IFileTypeComponentBuilder)
Helper method to create a file extractor so that it can be used by filter component builders.
Declaration
IFileExtractor BuildFileExtractor(IBilingualParser fileReader, IFileTypeComponentBuilder componentBuilder)
Parameters
Type | Name | Description |
---|---|---|
IBilingualParser | fileReader | |
IFileTypeComponentBuilder | componentBuilder |
Returns
Type | Description |
---|---|
IFileExtractor |
BuildFileExtractor(INativeExtractor, IFileTypeComponentBuilder)
Helper method to create a file extractor so that it can be used by filter component builders.
Declaration
IFileExtractor BuildFileExtractor(INativeExtractor fileReader, IFileTypeComponentBuilder componentBuilder)
Parameters
Type | Name | Description |
---|---|---|
INativeExtractor | fileReader | |
IFileTypeComponentBuilder | componentBuilder |
Returns
Type | Description |
---|---|
IFileExtractor |
BuildFileGenerator(IBilingualWriter)
Helper method to create a file generator so that it can be used by filter component builders.
Declaration
IFileGenerator BuildFileGenerator(IBilingualWriter bilingualWriter)
Parameters
Type | Name | Description |
---|---|---|
IBilingualWriter | bilingualWriter |
Returns
Type | Description |
---|---|
IFileGenerator |
BuildFileGenerator(INativeGenerator)
Helper method to create a file generator so that it can be used by filter component builders.
Declaration
IFileGenerator BuildFileGenerator(INativeGenerator nativeGenerator)
Parameters
Type | Name | Description |
---|---|---|
INativeGenerator | nativeGenerator |
Returns
Type | Description |
---|---|
IFileGenerator |
BuildFileTypeInformation()
Helper method to create file type information so that it can be used by filter component builders.
Declaration
IFileTypeInformation BuildFileTypeInformation()
Returns
Type | Description |
---|---|
IFileTypeInformation |
BuildGeneratorInfo()
Helper method to create generator information so that it can be used by filter component builders.
Declaration
IGeneratorInfo BuildGeneratorInfo()
Returns
Type | Description |
---|---|
IGeneratorInfo |
BuildNativeExtractor(INativeFileParser)
Helper method to create a native extractor so that it can be used by filter component builders.
Declaration
INativeExtractor BuildNativeExtractor(INativeFileParser nativeFileParser)
Parameters
Type | Name | Description |
---|---|---|
INativeFileParser | nativeFileParser |
Returns
Type | Description |
---|---|
INativeExtractor |
BuildNativeGenerator(INativeFileWriter)
Helper method to create a native generator so that it can be used by filter component builders.
Declaration
INativeGenerator BuildNativeGenerator(INativeFileWriter nativeFileWriter)
Parameters
Type | Name | Description |
---|---|---|
INativeFileWriter | nativeFileWriter |
Returns
Type | Description |
---|---|
INativeGenerator |
BuildNativeGenerator(IPersistentFileConversionProperties)
Helper function used by the file type manager implementation and other components that need to create a file generator component from a specific file type definition.
Creates and initializes a file generator that can be used to write native output files.
Declaration
IFileGenerator BuildNativeGenerator(IPersistentFileConversionProperties fileConversionProperties)
Parameters
Type | Name | Description |
---|---|---|
IPersistentFileConversionProperties | fileConversionProperties | Properties with information on the file being generated, including the id of the file type definition used to convert the original native file. This can either be the persistent file properties that were created when reading the original native file, or they can be retrieved from the bilingual parser. |
Returns
Type | Description |
---|---|
IFileGenerator | A file generator object that can be used to create a single native file. |
Remarks
This method may be used as a NativeGeneratorProvider delegate in the IMultiFileConverter.
void SetNativeGeneratorProvider(IFileTypeManager manager, IMultiFileConverter converter)
{
converter.NativeGeneratorProvider = new NativeGeneratorProvider(manager.BuildFileGenerator);
}
Exceptions
Type | Condition |
---|---|
FileTypeDefinitionNotFoundException | thrown if the specified file type definition ID is not one of the file type definitions in the file type manager |
BuildNativeGeneratorWithVerifiers(IPersistentFileConversionProperties)
This is an alternative implementation of the BuildNativeGenerator(IPersistentFileConversionProperties) method, which creates a generator with objects that will perform native verification of the generated file.
Declaration
IFileGenerator BuildNativeGeneratorWithVerifiers(IPersistentFileConversionProperties fileConversionProperties)
Parameters
Type | Name | Description |
---|---|---|
IPersistentFileConversionProperties | fileConversionProperties |
Returns
Type | Description |
---|---|
IFileGenerator |
BuildNativeSubContentExtractor(INativeFileParser)
Helper method to create a native sub-content extractor so that it can be used by filter component builders.
Declaration
INativeSubContentExtractor BuildNativeSubContentExtractor(INativeFileParser nativeFileParser)
Parameters
Type | Name | Description |
---|---|---|
INativeFileParser | nativeFileParser |
Returns
Type | Description |
---|---|
INativeSubContentExtractor |
BuildNativeSubContentGenerator(INativeFileWriter)
Helper method to create a native sub content generator so that it can be used by filter component builders.
Declaration
INativeSubContentGenerator BuildNativeSubContentGenerator(INativeFileWriter nativeFileWriter)
Parameters
Type | Name | Description |
---|---|---|
INativeFileWriter | nativeFileWriter |
Returns
Type | Description |
---|---|
INativeSubContentGenerator |
BuildPreviewSetsFactory()
Helper method to create a preview sets factory so that it can be used by filter compnent builders.
Declaration
IPreviewSetsFactory BuildPreviewSetsFactory()
Returns
Type | Description |
---|---|
IPreviewSetsFactory |
BuildQuickTagsFactory()
Helper method to create a QuickTags factory so that it can be used by filter component builders.
Declaration
IQuickTagsFactory BuildQuickTagsFactory()
Returns
Type | Description |
---|---|
IQuickTagsFactory |
BuildSubContentExtractor(IBilingualParser, IFileTypeComponentBuilder)
Helper method to create a sub-content extractor so that it can be used by filter component builders.
Declaration
ISubContentExtractor BuildSubContentExtractor(IBilingualParser fileReader, IFileTypeComponentBuilder componentBuilder)
Parameters
Type | Name | Description |
---|---|---|
IBilingualParser | fileReader | |
IFileTypeComponentBuilder | componentBuilder |
Returns
Type | Description |
---|---|
ISubContentExtractor |
BuildSubContentExtractor(INativeSubContentExtractor, IFileTypeComponentBuilder)
Helper method to create a sub-content file extractor so that it can be used by filter component builders.
Declaration
ISubContentExtractor BuildSubContentExtractor(INativeSubContentExtractor subContentReader, IFileTypeComponentBuilder componentBuilder)
Parameters
Type | Name | Description |
---|---|---|
INativeSubContentExtractor | subContentReader | |
IFileTypeComponentBuilder | componentBuilder |
Returns
Type | Description |
---|---|
ISubContentExtractor |
BuildSubContentGenerator(IBilingualWriter)
Helper method to create a sub content generator so that it can be used by filter component builders.
Declaration
ISubContentGenerator BuildSubContentGenerator(IBilingualWriter bilingualWriter)
Parameters
Type | Name | Description |
---|---|---|
IBilingualWriter | bilingualWriter |
Returns
Type | Description |
---|---|
ISubContentGenerator |
BuildSubContentGenerator(INativeSubContentGenerator)
Helper method to create a sub content generator so that it can be used by filter component builders.
Declaration
ISubContentGenerator BuildSubContentGenerator(INativeSubContentGenerator nativeSubContentGenerator)
Parameters
Type | Name | Description |
---|---|---|
INativeSubContentGenerator | nativeSubContentGenerator |
Returns
Type | Description |
---|---|
ISubContentGenerator |
BuildVerifierCollection()
Helper method to create a verifier collection so that it can be used by filter component builders.
Declaration
IVerifierCollection BuildVerifierCollection()
Returns
Type | Description |
---|---|
IVerifierCollection |
ClearFileTypeDefinitions()
Removes all file type definitions from the collection.
Declaration
void ClearFileTypeDefinitions()
CreateFileTypeDefinition(IFileTypeComponentBuilder, FileTypeProfile)
Creates a file type definition based on component builder and overrides the FileTypeInformation with the supplied profile override.
Declaration
IFileTypeDefinition CreateFileTypeDefinition(IFileTypeComponentBuilder componentBuilder, FileTypeProfile profileOverride)
Parameters
Type | Name | Description |
---|---|---|
IFileTypeComponentBuilder | componentBuilder | The component builder used to initialize the FileTypeDefinition |
FileTypeProfile | profileOverride | profile used to override the FileTypeInformation |
Returns
Type | Description |
---|---|
IFileTypeDefinition | The created IFileTypeDefinitionInstance |
CreateFileTypeDefinition(String)
Creates a file type definition based on the filter definition ID of component builder which should be used to create this filter.
Declaration
IFileTypeDefinition CreateFileTypeDefinition(string fileTypeDefinitionId)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileTypeDefinitionId | ID of component builder which should be used to create this filter |
Returns
Type | Description |
---|---|
IFileTypeDefinition | The created IFileTypeDefinitionInstance |
CreateFileTypeDefinition(String, FileTypeProfile)
Creates a file type definition based on the Id and a profile override. The FilterManager must discover the actual component builder associated with this definition and create a new definition based on it. If a profileOverride has been supplied, then this should override the FileTypeInformation for that definition.
Declaration
IFileTypeDefinition CreateFileTypeDefinition(string fileTypeDefinitionId, FileTypeProfile profileOverride)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileTypeDefinitionId | ID of component builder which should be used to create this filter |
FileTypeProfile | profileOverride | profile used to override the FileTypeInformation |
Returns
Type | Description |
---|---|
IFileTypeDefinition | The created IFileTypeDefinitionInstance |
FindFileTypeDefinition(FileTypeDefinitionId)
Locates a file type definition from the collection using ids.
Declaration
IFileTypeDefinition FindFileTypeDefinition(FileTypeDefinitionId id)
Parameters
Type | Name | Description |
---|---|---|
FileTypeDefinitionId | id |
Returns
Type | Description |
---|---|
IFileTypeDefinition | The corresponding file type definition, or |
GetAllMatchingFileTypeDefinitions(String, Language, Codepage, EventHandler<MessageEventArgs>)
Returns the file type definitions that can operate on the specified file.
Each file type definition is evaluated in order to determine if it can process the file, which may involve invoking the corresponding file sniffer.
Only file type definitions that are enabled and not hidden are evaluated.
Declaration
IEnumerable<Pair<IFileTypeDefinition, SniffInfo>> GetAllMatchingFileTypeDefinitions(string nativeFilePath, Language suggestedSourceLanguage, Codepage suggestedCodepage, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | nativeFilePath | The path to the file which is 'sniffed' in order to determine applicable file type definitions. |
Language | suggestedSourceLanguage | |
Codepage | suggestedCodepage | |
System.EventHandler<MessageEventArgs> | messageHandler | Optional handler for messages reported by any file sniffers invoked in the process.
You may pass |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Pair<IFileTypeDefinition, SniffInfo>> | File type definitions that can operate on the file specified, and the information from their file sniffers |
Remarks
If more than one file type definition is returned, the order corresponds to the order in which the definitions appear in the manager.
If all file types are enabled, the first file type definition
returned is the one that is used if calling one of the GetConverter
overloads.
Any messages generated during file sniffing are reported to the optional messageHandler
.
GetAllMatchingFileTypeDefinitions(String, EventHandler<MessageEventArgs>)
Returns the file type definitions that can operate on the specified file.
Each file type definition is evaluated in order to determine if it can process the file, which may involve invoking the corresponding file sniffer.
Only file type definitions that are enabled and not hidden are evaluated.
Declaration
IEnumerable<Pair<IFileTypeDefinition, SniffInfo>> GetAllMatchingFileTypeDefinitions(string nativeFilePath, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | nativeFilePath | The path to the file which is 'sniffed' in order to determine applicable file type definitions. |
System.EventHandler<MessageEventArgs> | messageHandler | Optional handler for messages reported by any file sniffers invoked in the process.
You may pass |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Pair<IFileTypeDefinition, SniffInfo>> | File type definitions that can operate on the file specified, and the information from their file sniffers |
Remarks
If more than one file type definition is returned, the order corresponds to the order in which the definitions appear in the manager.
If all file types are enabled, the first file type definition
returned is the one that is used if calling one of the GetConverter
overloads.
Any messages generated during file sniffing are reported to the optional messageHandler
.
GetBestMatchingFileTypeDefinition(String, Language, Codepage, EventHandler<MessageEventArgs>)
Returns the first file type definition that can operate on the specified file.
Declaration
Pair<IFileTypeDefinition, SniffInfo> GetBestMatchingFileTypeDefinition(string nativeFilePath, Language suggestedSourceLanguage, Codepage suggestedCodepage, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | nativeFilePath | |
Language | suggestedSourceLanguage | |
Codepage | suggestedCodepage | |
System.EventHandler<MessageEventArgs> | messageHandler |
Returns
Type | Description |
---|---|
Pair<IFileTypeDefinition, SniffInfo> |
GetBestMatchingFileTypeDefinition(String, EventHandler<MessageEventArgs>)
Returns the first file type definition that can operate on the specified file.
Declaration
Pair<IFileTypeDefinition, SniffInfo> GetBestMatchingFileTypeDefinition(string nativeFilePath, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | nativeFilePath | |
System.EventHandler<MessageEventArgs> | messageHandler |
Returns
Type | Description |
---|---|
Pair<IFileTypeDefinition, SniffInfo> |
GetConverter(IBilingualParser)
Creates and initializes a file converter to use a specific bilingual parser, and not output to anything in particular.
Declaration
IMultiFileConverter GetConverter(IBilingualParser bilingualParser)
Parameters
Type | Name | Description |
---|---|---|
IBilingualParser | bilingualParser |
Returns
Type | Description |
---|---|
IMultiFileConverter |
GetConverter(String, EventHandler<MessageEventArgs>)
Creates and initializes a file converter that can be used to read a single bilingual file, without outputting content to anything in particular.
Declaration
IMultiFileConverter GetConverter(string bilingualInputFilePath, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | bilingualInputFilePath | Name of the bilingual file to read |
System.EventHandler<MessageEventArgs> | messageHandler | An (optional) message handler implementation that will receive any messages reported
from file sniffers invoked in the process. If a converter is returned, this message handler will also have
been connected to the Message event on the converter. You may specify |
Returns
Type | Description |
---|---|
IMultiFileConverter |
GetConverter(String, String, CultureInfo, Codepage, EventHandler<MessageEventArgs>)
Creates and initializes a file converter in order to create a bilingual file. The native fileType used for parsing is defined by the fileTypeDefinitionId - no sniffing is done
Declaration
IMultiFileConverter GetConverter(string fileTypeDefinitionId, string filePath, CultureInfo sourceLanguage, Codepage suggestedCodepage, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileTypeDefinitionId | |
System.String | filePath | |
System.Globalization.CultureInfo | sourceLanguage | |
Codepage | suggestedCodepage | |
System.EventHandler<MessageEventArgs> | messageHandler |
Returns
Type | Description |
---|---|
IMultiFileConverter |
GetConverter(String[], CultureInfo, Codepage, EventHandler<MessageEventArgs>)
Creates and initializes a file converter for reading native files, without passing the output to anything.
Declaration
IMultiFileConverter GetConverter(string[] nativeFilePaths, CultureInfo sourceLanguage, Codepage suggestedCodepage, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nativeFilePaths | The native files to be converted |
System.Globalization.CultureInfo | sourceLanguage | Expected source language of the files. The same source (and target) language must be used for all the files processed with a single converter instance. If the language can be determined automatically from the content of the file (e.g. when reading a bilingual format such as TTX), this parameter may be ignored by the parser. If this parameter is left undefined, it is up to the file sniffer and/or parser to try to determine the language. Parser components may report an error or a warning if they cannot reliably identify the language. |
Codepage | suggestedCodepage | A rough guess of what encoding the files use. This is normally set to the default codepage
for the language, but can also be |
System.EventHandler<MessageEventArgs> | messageHandler | An (optional) message handler implementation that will receive any messages reported
from file sniffers invoked in the process. If a converter is returned, this message handler will also be
connected to the Message event on the converter. You may specify |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter object initialized to read the files, based on information from the best matching file type definitions. |
Exceptions
Type | Condition |
---|---|
OneOrMoreFilesNotSupportedException | Thrown if there are files for which no file type definition in the file type manager can be used. |
GetConverterToBilingual(IBilingualParser, IBilingualDocumentGenerator, BilingualDocumentOutputPropertiesProvider)
Creates and initializes a file converter for an existing bilingual parser and writer.
Declaration
IMultiFileConverter GetConverterToBilingual(IBilingualParser bilingualParser, IBilingualDocumentGenerator writer, BilingualDocumentOutputPropertiesProvider outputSettingsProvider)
Parameters
Type | Name | Description |
---|---|---|
IBilingualParser | bilingualParser | Bilingual parser to be used for input with the converter |
IBilingualDocumentGenerator | writer | Bilingual writer to use as output with the converter |
BilingualDocumentOutputPropertiesProvider | outputSettingsProvider | Implementation of the output settings provider for bilingual
document files. Will be passed to the multi-file converter and used for writing bilingual document files.
If the bilingual document generator does not have a bilingual document file writer, you can pass |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter object initialized to read content using the specified parser and output to the specified writer. To use the file converter, add your own bilingual processors to the converter, and call Parse() or ParseNext() to process the content. |
GetConverterToBilingual(String, IBilingualDocumentGenerator, BilingualDocumentOutputPropertiesProvider, EventHandler<MessageEventArgs>)
Creates and initializes a file converter for a single file, typically of the default bilingual file type. The specified bilingual document generator will be used for output.
The file type definitions are tested in order, and the first file type definition that matches the input file is used. The following steps are used to determine if a file type definition matches the file:
- The regular expression is evaluated against the name of the file to be converted. If it does not match, the file type definition is not used.
- If a file sniffer is defined for the file type definition, it gets applied to the file. If the file sniffer does not indicate that the file is supported, the file type definition is not used.
Declaration
IMultiFileConverter GetConverterToBilingual(string bilingualInputFilePath, IBilingualDocumentGenerator writer, BilingualDocumentOutputPropertiesProvider outputSettingsProvider, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | bilingualInputFilePath | The file to be converted. The language and code page of this file is expected to be automatically detected by the file sniffer, no external hints should be necessary. |
IBilingualDocumentGenerator | writer | Bilingual writer to use as output with the converter |
BilingualDocumentOutputPropertiesProvider | outputSettingsProvider | Implementation of the output settings provider for bilingual
document files. Will be passed to the multi-file converter and used for writing bilingual document files.
If the bilingual document generator does not have a bilingual document file writer, you can pass |
System.EventHandler<MessageEventArgs> | messageHandler | An (optional) message handler implementation that will receive any messages reported
from file sniffers invoked in the process. If a converter is returned, this message handler will also be
connected to the Message event on the converter. You may specify |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter object initialized to read the file, based on information from the best matching file type definition. To use the file converter, add your own bilingual processors to the converter, and call Parse() or ParseNext() to process the file. |
Exceptions
Type | Condition |
---|---|
OneOrMoreFilesNotSupportedException | Thrown if no file type definition in the file type manager can be used. |
GetConverterToBilingual(String[], IBilingualDocumentGenerator, BilingualDocumentOutputPropertiesProvider, CultureInfo, Codepage, EventHandler<MessageEventArgs>)
Creates and initializes a file converter using the filters that best match a set of native files. The file converter can then be used to process all of the files as one document. The specified bilingual writer will be used for output.
The file type definitions are tested in sequence, and the first file type definition that matches a file is used for each file. The following steps are used to determine if a file type definition matches a file:
- The regular expression is evaluated against the name of the file to be converted. If it does not match, the file type definition is not used.
- If a file sniffer is defined for the file type definition, it gets applied to the file. If the file sniffer does not indicate that the file is supported, the file type definition is not used.
Declaration
IMultiFileConverter GetConverterToBilingual(string[] nativeFilePaths, IBilingualDocumentGenerator writer, BilingualDocumentOutputPropertiesProvider outputSettingsProvider, CultureInfo sourceLanguage, Codepage suggestedCodepage, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nativeFilePaths | The native files to be converted |
IBilingualDocumentGenerator | writer | Bilingual writer to use as output with the converter |
BilingualDocumentOutputPropertiesProvider | outputSettingsProvider | Implementation of the output settings provider for bilingual
document files. Will be passed to the multi-file converter and used for writing bilingual document files.
If the bilingual document generator does not have a bilingual document file writer, you can pass |
System.Globalization.CultureInfo | sourceLanguage | Expected source language of the files. The same source (and target) language must be used for all the files processed with a single converter instance. If the language can be determined automatically from the content of the file (e.g. when reading a bilingual format such as TTX), this parameter may be ignored by the parser. If this parameter is left undefined, it is up to the file sniffer and/or parser to try to determine the language. Parser components may report an error or a warning if they cannot reliably identify the language. |
Codepage | suggestedCodepage | A rough guess on what encoding the files use. This is normally set to the default code page
for the language, but can also be |
System.EventHandler<MessageEventArgs> | messageHandler | An (optional) message handler implementation that will receive any messages reported
from file sniffers invoked in the process. If a converter is returned, this message handler will also
be connected to the Message event on the converter. You may specify |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter object initialized to read the files, based on information from the best matching file type definitions. To use the file converter, add your own bilingual processors to the converter and call Parse() or ParseNext() to process the native files. |
Remarks
To convert bilingual files to native, you would typically rather use GetConverterToNative(String, OutputPropertiesProvider, EventHandler<MessageEventArgs>).
Exceptions
Type | Condition |
---|---|
OneOrMoreFilesNotSupportedException | thrown if there are files for which no file type definition in the file type manager can be used. |
GetConverterToDefaultBilingual(IBilingualParser, String)
Creates and initializes a file converter to write a bilingual output file in the default format, reading input from a specified bilingual parser.
Declaration
IMultiFileConverter GetConverterToDefaultBilingual(IBilingualParser bilingualParser, string bilingualOutputFilePath)
Parameters
Type | Name | Description |
---|---|---|
IBilingualParser | bilingualParser | The parser to be used for input |
System.String | bilingualOutputFilePath | Full path to the bilingual file to be created |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter object initialized to read content using the bilingual parser and write an output file in the default bilingual format with the specified name. To use the file converter, add your own bilingual processors to the converter and call Parse() or ParseNext(). |
GetConverterToDefaultBilingual(String, String, EventHandler<MessageEventArgs>)
Creates and initializes a file converter in order to read a single (typically bilingual) input file and write a bilingual output file in the default format.
The converter will automatically use the file type that best matches the file to be converted.
The file type definitions are each tested in sequence, and the first file type definition that matches the input file is used. The following steps are used to determine if a file type definition matches:
- The regular expression is evaluated against the name of the file to be converted. If it does not match, the file type definition is not used.
- If a file sniffer is defined for the file type definition, it is applied to the file. If the file sniffer does not indicate that the file is supported, the file type definition is not used.
Declaration
IMultiFileConverter GetConverterToDefaultBilingual(string bilingualInputFilePath, string bilingualOutputFilePath, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | bilingualInputFilePath | The native files to be converted |
System.String | bilingualOutputFilePath | Full path to the bilingual file to be created |
System.EventHandler<MessageEventArgs> | messageHandler | (optional) A message handler implementation that will receive any messages reported
from file sniffers invoked in the process. If a converter is returned, this message handler will also be
connected to the Message event on the converter. You may specify |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter object initialized to read the file, based on information from the best matching file type definition that will create an output file in the default bilingual format with the specified name. To use the file converter, add your own bilingual processors to the converter and call Parse() or ParseNext(). |
Remarks
To convert bilingual files to native you would typically use GetConverterToNative(String, OutputPropertiesProvider, EventHandler<MessageEventArgs>).
Exceptions
Type | Condition |
---|---|
OneOrMoreFilesNotSupportedException | Thrown if no file type definition in the file type manager can be used. |
GetConverterToDefaultBilingual(String, String, String, CultureInfo, Codepage, EventHandler<MessageEventArgs>)
Creates and initializes a file converter in order to create a bilingual file in the default format. The converter will only use the file type specified by the fileTypeDefinitionId and bypasses the sniffer
Declaration
IMultiFileConverter GetConverterToDefaultBilingual(string fileTypeDefinitionId, string filePath, string bilingualOutputFilePath, CultureInfo sourceLanguage, Codepage suggestedCodepage, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileTypeDefinitionId | |
System.String | filePath | |
System.String | bilingualOutputFilePath | |
System.Globalization.CultureInfo | sourceLanguage | |
Codepage | suggestedCodepage | |
System.EventHandler<MessageEventArgs> | messageHandler |
Returns
Type | Description |
---|---|
IMultiFileConverter |
GetConverterToDefaultBilingual(String[], String, CultureInfo, Codepage, EventHandler<MessageEventArgs>)
Creates and initializes a file converter in order to create a bilingual file in the default format.
The converter will automatically use the filters that best match the native files to be converted. These converters are selected as described below.
The file type definitions are each tested in sequence, and the first file type definition that matches a file is used for each file. The following steps are used to determine if a file type definition matches a file:
- The regular expression is evaluated against the name of the file to be converted. If it does not match, the file type definition is not used.
- If a file sniffer is defined for the file type definition, it is applied to the file. If the file sniffer does not indicate that the file is supported, the file type definition is not used.
Declaration
IMultiFileConverter GetConverterToDefaultBilingual(string[] nativeFilePaths, string bilingualOutputFilePath, CultureInfo sourceLanguage, Codepage suggestedCodepage, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nativeFilePaths | The native files to be converted. |
System.String | bilingualOutputFilePath | Full path to the bilingual file to be created. |
System.Globalization.CultureInfo | sourceLanguage | Expected source language of the files. The same source (and target) language must be used for all the files processed with a single converter instance. If the language can be determined automatically from the content of the file (e.g. when reading a bilingual format such as TTX), this parameter may be ignored by the parser. If this parameter is left undefined, it is up to the file sniffer and/or parser to try to determine the language. Parser components may report an error or a warning if they cannot reliably identify the language. |
Codepage | suggestedCodepage | A rough guess of what encoding the files use. This is normally set to the default codepage
for the language, but can also be |
System.EventHandler<MessageEventArgs> | messageHandler | An (optional) message handler implementation that will receive any messages reported
from file sniffers invoked in the process. If a converter is returned, this message handler will also have
been connected to the Message event on the converter. You may specify |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter object initialized to read the files, based on information from the best matching file type definitions. To use the file converter, add your own bilingual processors to the converter and call Parse() or ParseNext() to process the native files. |
Remarks
To convert bilingual files to native you would typically use GetConverterToNative(String, OutputPropertiesProvider, EventHandler<MessageEventArgs>).
Examples
This example shows how this method could be used convert a bunch of native files into a single SDL XLIFF document.
void ConvertFilesToXliff(IFileTypeManager manager, string[] nativeFiles, CultureInfo language, Codepage suggestedCodepage, string xliffFilePath)
{
IMultiFileConverter converter = manager.GetConverterToDefaultBilingual(nativeFiles[], xliffFilePath, language, suggestedCodepage, null, settingsBundle);
converter.Parse();
}
Exceptions
Type | Condition |
---|---|
OneOrMoreFilesNotSupportedException | thrown if there are files for which no file type definition in the file type manager can be used. |
GetConverterToNative(IBilingualParser, OutputPropertiesProvider)
Creates a converter for writing native output files for content read by a specified bilingual parser.
Declaration
IMultiFileConverter GetConverterToNative(IBilingualParser bilingualParser, OutputPropertiesProvider outputSettingsProvider)
Parameters
Type | Name | Description |
---|---|---|
IBilingualParser | bilingualParser | The parser that will be used for input |
OutputPropertiesProvider | outputSettingsProvider | (Optional) implementation of the output settings provider that will be passed to the multi-file converter and used for writing files as native If this parameter is provided (i.e. not |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter that may be used to convert bilingual content to native output files |
GetConverterToNative(String, OutputPropertiesProvider, EventHandler<MessageEventArgs>)
Creates a converter for parsing a single file and writing native output files.
This is intended for bilingual file types, in which the languages and codepage can be deducted automatically from the file content.
This version is typically used for parsing SDL XLIFF documents (where support for these have been installed as another bilingual file type). However, it could also be used for processing individual native files in which source language (and codepage) can be deducted from the file content.
Declaration
IMultiFileConverter GetConverterToNative(string bilingualInputFilePath, OutputPropertiesProvider outputSettingsProvider, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String | bilingualInputFilePath | Full path to a bilingual (typically SDL XLIFF) file |
OutputPropertiesProvider | outputSettingsProvider | (Optional) implementation of the output settings provider that will be passed to the multi-file converter and used for writing files as native. If this parameter is provided (i.e. not null), the returned converter will be initialized to use this file type manager to create native file generators, and the specified output settings provider will be used to determine output properties for the native files when they are created. |
System.EventHandler<MessageEventArgs> | messageHandler | An (optional) message handler implementation that will receive any messages reported
from file sniffers invoked in the process. If a converter is returned, this message handler will also
be connected to the Message event on the converter. You may specify |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter that may be used to convert bilingual files to native output files |
Remarks
If language (and/or codepage) cannot be successfully determined by the file type components, an exception should be thrown.
Examples
The following code example shows how to convert an SDL XLIFF file into native target language files.
void SaveAsTarget(IFileTypeManager manager, string xliffFilePath, string outputFolder)
{
FolderPathProvider pathProvider = new FolderPathProvider(outputFolder);
IMultiFileConverter converter = manager.GetConverterToNative(xliffFilePath, pathProvider.Provider, settingsBundle);
converter.AddBilingualProcessor(new SourceToTargetCopier(ExistingContentHandling.Preserve));
converter.Parse();
}
Note that a SourceToTargetCopier object is used to ensure that ParagraphUnits without target content are output as source (they would otherwise be emitted as nothing, which could lead to unexpected results).
GetConverterToNative(String[], OutputPropertiesProvider, CultureInfo, Codepage, EventHandler<MessageEventArgs>)
Creates and initializes a file converter for reading native files, doing processing on them and creating native files as output in one single pass.
The file type definitions are tested in sequence, and the first file type definition that matches a file is used for each file. The following steps are used to determine if a file type definition matches a file:
- The regular expression is evaluated against the name of the file to be converted. If it does not match, the file type definition is not used.
- If a file sniffer is defined for the file type definition, it is applied to the file. If the file sniffer does not indicate that the file is supported, the file type definition is not used.
Declaration
IMultiFileConverter GetConverterToNative(string[] nativeFilePaths, OutputPropertiesProvider outputSettingsProvider, CultureInfo sourceLanguage, Codepage suggestedCodepage, EventHandler<MessageEventArgs> messageHandler)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nativeFilePaths | The native files to be converted |
OutputPropertiesProvider | outputSettingsProvider | Implementation of the output settings provider that will be passed to the multi-file converter and used for writing files as native. The returned converter will be initialized to use this file type manager to create native file generators, and the specified output settings provider will be used to determine the output properties for the native files when they are created. |
System.Globalization.CultureInfo | sourceLanguage | Expected source language of the files. The same source (and target) language must be used for all the files processed with a single converter instance. If the language can be determined automatically from the content of the file (e.g. when reading a bilingual format such as TTX), this parameter may be ignored by the parser. If this parameter is left undefined, it is up to the file sniffer and/or parser to try to determine the language. Parser components may report an error or a warning if they cannot reliably identify the language. |
Codepage | suggestedCodepage | A rough guess of what encoding the files use. This is normally set to the default codepage
for the language, but can also be |
System.EventHandler<MessageEventArgs> | messageHandler | An (optional) message handler implementation that will receive any messages reported
from file sniffers invoked in the process. If a converter is returned, this message handler will also be
connected to the Message event on the converter. You may specify |
Returns
Type | Description |
---|---|
IMultiFileConverter | A file converter object initialized to read the files and write corresponding output files based on the output settings provider. To use the file converter, add your own bilingual processors to the converter and call Parse() or ParseNext() to process the native files. |
Exceptions
Type | Condition |
---|---|
OneOrMoreFilesNotSupportedException | thrown if there are files for which no file type definition in the file type manager can be used. |
InsertFileTypeDefinition(Int32, IFileTypeDefinition)
Inserts a file type definition into the collection at a specific priority position.
Declaration
void InsertFileTypeDefinition(int index, IFileTypeDefinition filterDefinition)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | 0-based index indicating the file type definition's priority in relation to the other currently known file type definitions. |
IFileTypeDefinition | filterDefinition |
RemoveFileTypeDefinition(IFileTypeDefinition)
Removes a file type definition from the collection. If no such file type definition exists in the collection, nothing happens.
Declaration
void RemoveFileTypeDefinition(IFileTypeDefinition filterDefinition)
Parameters
Type | Name | Description |
---|---|---|
IFileTypeDefinition | filterDefinition |