Class SniffInfo
Information returned from Sniff(string, Language, Codepage, INativeTextLocationMessageReporter, ISettingsGroup). This class also allows you to store key/value pairs that the parser may need to read during parsing.
Inherited Members
Namespace: SdlSdl.FileTypeSupportFrameworkNativeApi
Assembly: Sdl.FileTypeSupport.Framework.Core.dll
Syntax
public class SniffInfo : IMetaDataContainer, ICloneable, ISupportsPersistenceId
Remarks
Communicates whether the file is considered valid by the file sniffer; may contain additional information such as the detected source and target languages, encoding of the file, etc.
Custom metadata can also be stored and accessed via the IMetaDataContainer implementation.
If the file type is supported and further processed, this information is passed to all file processing components that implement INativeContentCycleAware as the FileSnifferInfo when the framework calls SetFileProperties(IFileProperties).
Constructors
SniffInfo()
Default constructor, creates an uninitialized object where IsSupported is false and DetectedEncoding is null.
Declaration
public SniffInfo()
SniffInfo(SniffInfo)
Copy constructor used by the Clone() method.
Performs a deep clone of the other object.
Declaration
protected SniffInfo(SniffInfo other)
Parameters
Type | Name | Description |
---|---|---|
SniffInfo | other | Object to clone from |
Properties
DetectedEncoding
If the file sniffer detects or guesses which encoding is used in the file, it may communicate this to the other parser components by setting this property.
Declaration
public Pair<Codepage, DetectionLevel> DetectedEncoding { get; set; }
Property Value
Type | Description |
---|---|
PairCodepageDetectionLevel |
DetectedSourceLanguage
If the file sniffer detects or guesses the source language in the file, it can be communicated to the framework by setting this property.
Declaration
public Pair<Language, DetectionLevel> DetectedSourceLanguage { get; set; }
Property Value
Type | Description |
---|---|
PairLanguageDetectionLevel |
DetectedTargetLanguage
If the file sniffer detects or guesses the target language of a bilingual file, it can be communicated to the framework by setting this property.
Declaration
public Pair<Language, DetectionLevel> DetectedTargetLanguage { get; set; }
Property Value
Type | Description |
---|---|
PairLanguageDetectionLevel |
HasMetaData
True if there are any key/value pairs of metadata in the sniff info
Declaration
public bool HasMetaData { get; }
Property Value
Type | Description |
---|---|
bool |
IsSupported
The file sniffer sets this property to true in order to indicate that the corresponding file type definition can be used for processing this file.
Declaration
public bool IsSupported { get; set; }
Property Value
Type | Description |
---|---|
bool |
this[string]
Convenience getter and setter for metadata using indexer syntax.
The getter functionality is equivalent to calling SetMetaData(string, string), the setter functionality is equivalent to GetMetaData(string).
Declaration
public string this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
string | key | Must not be |
Property Value
Type | Description |
---|---|
string | The corresponding value, or |
MetaData
Iterator for all metadata key/value pairs
Declaration
public IEnumerable<KeyValuePair<string, string>> MetaData { get; }
Property Value
Type | Description |
---|---|
IEnumerableKeyValuePairstringstring |
MetaDataCount
Number of key/value pairs of metadata
Declaration
public int MetaDataCount { get; }
Property Value
Type | Description |
---|---|
int |
PersistenceId
The persistence ID associated with an object may be used by implementations during operations such as serialization and de-serialization of the object model.
Declaration
public int PersistenceId { get; set; }
Property Value
Type | Description |
---|---|
int |
SuggestedTargetEncoding
The file sniffer's suggestion on what type of encoding would be suitable when generating a translated version of this file.
Declaration
public EncodingCategory SuggestedTargetEncoding { get; set; }
Property Value
Type | Description |
---|---|
EncodingCategory |
Methods
ClearMetaData()
Removes all metadata key/value pairs.
Declaration
public void ClearMetaData()
Clone()
Deep clone this object
Declaration
public object Clone()
Returns
Type | Description |
---|---|
object |
Equals(object)
True if all properties and values are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj |
Returns
Type | Description |
---|---|
bool |
Overrides
GetHashCode()
Computed by combining all properties and values
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
GetMetaData(string)
Retrieves the metadata value for the specified key
Declaration
public string GetMetaData(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | Must not be |
Returns
Type | Description |
---|---|
string |
|
MetaDataContainsKey(string)
Determines if a metadata value exists for the specified key
Declaration
public bool MetaDataContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | Must not be |
Returns
Type | Description |
---|---|
bool | True if a value exists for the key |
RemoveMetaData(string)
Removes the metadata value for the specified key from the collection. If no value exists for this key, nothing will happen.
Declaration
public bool RemoveMetaData(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | Must not be |
Returns
Type | Description |
---|---|
bool |
|
SetMetaData(string, string)
Sets the metadata value for the specified key
Declaration
public void SetMetaData(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
string | key | Must not be |
string | value | Must not be |
Remarks
If no value exists for the key, one will be created. If a value already exists for the key, it will be overwritten.