-
Notifications
You must be signed in to change notification settings - Fork 0
Definition Class
Represents a file type definition, including associated extensions, MIME type, and related metadata.
Namespace: Rheo.Storage.Analyzing.Models
Assembly: Rheo.Storage.dll
[MessagePackObject]
public partial class Definition| Property | Type | Description |
|---|---|---|
| FileType | String | Gets or sets the file type associated with the type definition. |
| Extensions | String[] | Gets or sets the file extension associated with the type definition. |
| MimeType | String | Gets or sets the MIME type associated with the content. |
| Remarks | String | Gets or sets additional information or notes related to the current context. |
| Signature | Signature | Gets or sets the digital signature associated with the current object. |
| PriorityLevel | Int32 | Gets or sets the priority level of the definition. |
The Definition class is used to describe file type characteristics and is typically populated from file definition packages. It uses MessagePack serialization for efficient storage and transmission.
This class is commonly used in file analysis scenarios where files need to be identified based on their binary signatures, file extensions, and MIME types.
Gets or sets the file type associated with the type definition.
[Key(0)]
public string FileType { get; set; }The name or description of the file type (e.g., "Portable Network Graphics", "ZIP Archive").
This property provides a human-readable name for the file format. It is typically used for display purposes and logging.
Gets or sets the file extension associated with the type definition.
[Key(1)]
public string[] Extensions { get; set; }String[]
An array of file extensions associated with this file type (e.g., [".png"], [".zip", ".jar"]).
Multiple extensions may be associated with a single file type. Extensions typically include the leading dot character.
Gets or sets the MIME type associated with the content.
[Key(2)]
public string MimeType { get; set; }The MIME type string (e.g., "image/png", "application/zip").
The MIME type follows the standard format defined in RFC 6838. It is used for content type identification in HTTP headers and other protocols.
Gets or sets additional information or notes related to the current context.
[Key(3)]
public string Remarks { get; set; }Additional notes, version information, or context about the file type.
Gets or sets the digital signature associated with the current object.
[Key(4)]
public Signature Signature { get; set; }A Signature object containing patterns and strings used to identify this file type.
The signature contains the byte patterns (magic numbers) and optional string sequences used by the file analyzer to identify files of this type.
Gets or sets the priority level of the definition.
[Key(5)]
public int PriorityLevel { get; set; }The priority level, where higher values indicate higher priority. Default is 0.
When multiple definitions match a file, the priority level can be used to determine which definition should be preferred.
Returns a string representation of the definition.
public override string ToString()A string in the format: FileType (MimeType) [Extensions]
var definition = new Definition
{
FileType = "Portable Network Graphics",
MimeType = "image/png",
Extensions = new[] { ".png" }
};
Console.WriteLine(definition.ToString());
// Output: Portable Network Graphics (image/png) [.png]The following example demonstrates how to create a file type definition:
using Rheo.Storage.Analyzing.Models;
var pngDefinition = new Definition
{
FileType = "Portable Network Graphics",
Extensions = new[] { ".png" },
MimeType = "image/png",
Remarks = "PNG image format with lossless compression",
Signature = new Signature
{
Patterns = new List<Pattern>
{
new Pattern { Position = 0, Data = new byte[] { 0x89, 0x50, 0x4E, 0x47 } }
}
},
PriorityLevel = 100
};The following example shows how definitions are typically used:
using Rheo.Storage.Analyzing;
using Rheo.Storage.Analyzing.Models.Result;
string filePath = @"C:\Images\photo.png";
AnalysisResult result = FileAnalyzer.AnalyzeFile(filePath);
if (result.Definitions.Count > 0)
{
var topMatch = result.Definitions.Peek();
var definition = topMatch.Subject;
Console.WriteLine($"File Type: {definition.FileType}");
Console.WriteLine($"MIME Type: {definition.MimeType}");
Console.WriteLine($"Extensions: {string.Join(", ", definition.Extensions)}");
}This class is not thread-safe. When accessing instances from multiple threads, use appropriate synchronization mechanisms.
-
Storage Objects
-
Storage Information
-
Platform-Specific
-
Content-Type Analysis
-
Results
-
Models
-
-
Events & Progress