Click or drag to resize
INativeFileSniffer Interface
A file sniffer is a component that gets invoked to determine if a particular file can be processed.

If the file is supported, the file sniffer may also detect the language and the encoding of a given file, in addition to any other information that will be useful to set up the parser to correctly process it.

Namespace: Sdl.FileTypeSupport.Framework.NativeApi
Assembly: Sdl.FileTypeSupport.Framework.Core (in Sdl.FileTypeSupport.Framework.Core.dll) Version: 1.0.0.0 (1.0.2343.0)
Syntax
public interface INativeFileSniffer

The INativeFileSniffer type exposes the following members.

Methods
  NameDescription
Public methodSniff
Called by the framework to invoke the file sniffer for a specific file.
Top
Remarks

File sniffers allow the framework to distinguish between different file types that use the same file extension. A file sniffer is expected to look at the actual file content to determine if the file is supported.

The file sniffer implementation should return a SniffInfo instance where the IsSupported is set to true if the file is of the expected type.

The file sniffer may also attempt to automatically detect the encoding and the source (and target) language of the file. When detecting such things, the file sniffer also specifies a confidence level for the detection, which allows applications to determine whether they may need to ask the user for additional information or not.

The file type manager invokes the Sniff(String, Language, Codepage, INativeTextLocationMessageReporter, ISettingsGroup) method on a file sniffer associated with a file type definition to determine if the file is of a type that can be processed.

The file sniffer implementation must be stateless and thread safe, since for performance reasons the file sniffer may be cached and re-used across multiple files, possibly also in a multi-threaded environment. The easiest way to accomplish this is by ensuring that the Sniff(String, Language, Codepage, INativeTextLocationMessageReporter, ISettingsGroup) implementation does not modify any class member fields and to avoid using static variables.

The file sniffer is also recommended (but not required) to implement IFileTypeDefinitionAware. If this interface is implemented, it will be used by the framework to communicate the file type definition used to instantiate the sniffer.

See Also
Community
Edit
Be the first to Edit the community content of this topic.
Comments