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.
Inheritance
Inherited Members
Namespace: Sdl.FileTypeSupport.Framework.NativeApi
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 |
---|---|
Pair<Codepage, DetectionLevel> |
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 |
---|---|
Pair<Language, DetectionLevel> |
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 |
---|---|
Pair<Language, DetectionLevel> |
HasMetaData
True if there are any key/value pairs of metadata in the sniff info
Declaration
public bool HasMetaData { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
---|---|
System.Boolean |
Item[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 |
---|---|---|
System.String | key | Must not be |
Property Value
Type | Description |
---|---|
System.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 |
---|---|
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.String>> |
MetaDataCount
Number of key/value pairs of metadata
Declaration
public int MetaDataCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
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 |
---|---|
System.Int32 |
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 |
---|---|
System.Object |
Equals(Object)
True if all properties and values are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
GetHashCode()
Computed by combining all properties and values
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
GetMetaData(String)
Retrieves the metadata value for the specified key
Declaration
public string GetMetaData(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Must not be |
Returns
Type | Description |
---|---|
System.String |
|
MetaDataContainsKey(String)
Determines if a metadata value exists for the specified key
Declaration
public bool MetaDataContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Must not be |
Returns
Type | Description |
---|---|
System.Boolean | 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 |
---|---|---|
System.String | key | Must not be |
Returns
Type | Description |
---|---|
System.Boolean |
|
SetMetaData(String, String)
Sets the metadata value for the specified key
Declaration
public void SetMetaData(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Must not be |
System.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.