-
Notifications
You must be signed in to change notification settings - Fork 0
Package Class
Represents a package containing a collection of file type definitions, version information, creation date, and associated tags.
Namespace: Rheo.Storage.Analyzing.Models
Assembly: Rheo.Storage.dll
[MessagePackObject]
public partial class Package| Property | Type | Description |
|---|---|---|
| Version | String | Gets or sets the version of the package. |
| CreatedAt | DateTime | Gets or sets the UTC date and time when the package was created. |
| Tags | PackageTag | Gets or sets the tags that describe the state or characteristics of the package. |
| TotalDefinitions | Int32 | Gets the total number of file type definitions in the package. |
| TotalMimeTypes | Int32 | Gets the total number of distinct MIME types represented in the package definitions. |
| Definitions | List<Definition> | Gets or sets the list of file type definitions contained in the package. |
The Package class serves as a container for file type definition data. It uses MessagePack serialization for efficient storage and transmission of definition databases.
Packages are typically loaded from .rpkg files that contain comprehensive file type identification data.
Gets or sets the version of the package.
[Key(0)]
public string Version { get; set; }The version string of the package (e.g., "1.0.0", "2.1.3-beta").
Gets or sets the UTC date and time when the package was created.
[Key(1)]
public DateTime CreatedAt { get; set; }The creation timestamp in UTC.
The default value is the current UTC time when the package instance is created.
Gets or sets the tags that describe the state or characteristics of the package.
[Key(2)]
public PackageTag Tags { get; set; }A combination of flags indicating the package's status and source.
Tags can be combined using bitwise operations to indicate multiple states.
Gets the total number of file type definitions in the package.
[JsonIgnore]
[IgnoreMember]
public int TotalDefinitions { get; }The count of definitions in the Definitions collection.
This property is not serialized and is computed dynamically from the Definitions collection.
Gets the total number of distinct MIME types represented in the package definitions.
[JsonIgnore]
[IgnoreMember]
public int TotalMimeTypes { get; }The number of unique MIME types across all definitions.
This property is not serialized and is computed dynamically by enumerating distinct MIME types from all definitions.
Gets or sets the list of file type definitions contained in the package.
[Key(3)]
public List<Definition> Definitions { get; set; }The collection of file type definitions.
Represents tags that describe the state or characteristics of a package.
[Flags]
public enum PackageTag| Field | Value | Description |
|---|---|---|
| None | 0 | No tag is specified. |
| Stable | 1 | The package is stable and production-ready. |
| Beta | 2 | The package is in beta and may be subject to changes. |
| Deprecated | 4 | The package is deprecated and should not be used. |
| Experimental | 8 | The package is experimental and may be unstable. |
| TrID | 16 | The package is associated with TrID file type definitions. |
| Validated | 32 | The package has been validated. |
The PackageTag enumeration uses the [Flags] attribute, allowing multiple tags to be combined.
The following example demonstrates how to create a package with file type definitions:
using Rheo.Storage.Analyzing.Models;
var package = new Package
{
Version = "1.0.0",
CreatedAt = DateTime.UtcNow,
Tags = PackageTag.Stable | PackageTag.Validated,
Definitions = new List<Definition>
{
new Definition
{
FileType = "Portable Network Graphics",
Extensions = new[] { ".png" },
MimeType = "image/png",
Signature = new Signature
{
Patterns = new List<Pattern>
{
new Pattern { Position = 0, Data = new byte[] { 0x89, 0x50, 0x4E, 0x47 } }
}
}
},
new Definition
{
FileType = "JPEG Image",
Extensions = new[] { ".jpg", ".jpeg" },
MimeType = "image/jpeg",
Signature = new Signature
{
Patterns = new List<Pattern>
{
new Pattern { Position = 0, Data = new byte[] { 0xFF, 0xD8, 0xFF } }
}
}
}
}
};
Console.WriteLine($"Package contains {package.TotalDefinitions} definitions");
Console.WriteLine($"Package contains {package.TotalMimeTypes} MIME types");The following example shows how to work with package tags:
using Rheo.Storage.Analyzing.Models;
var package = new Package
{
Version = "2.0.0-beta",
Tags = PackageTag.Beta | PackageTag.TrID
};
// Check if package has specific tags
bool isBeta = package.Tags.HasFlag(PackageTag.Beta);
bool isStable = package.Tags.HasFlag(PackageTag.Stable);
Console.WriteLine($"Is Beta: {isBeta}"); // True
Console.WriteLine($"Is Stable: {isStable}"); // False
// Add a tag
package.Tags |= PackageTag.Validated;
// Remove a tag
package.Tags &= ~PackageTag.Beta;The following example demonstrates how to query package information:
using Rheo.Storage.Analyzing.Models;
void DisplayPackageInfo(Package package)
{
Console.WriteLine($"Package Version: {package.Version}");
Console.WriteLine($"Created: {package.CreatedAt:yyyy-MM-dd HH:mm:ss} UTC");
Console.WriteLine($"Total Definitions: {package.TotalDefinitions}");
Console.WriteLine($"Total MIME Types: {package.TotalMimeTypes}");
Console.WriteLine($"Tags: {package.Tags}");
// Group definitions by MIME type
var groupedByMime = package.Definitions
.GroupBy(d => d.MimeType)
.OrderByDescending(g => g.Count());
Console.WriteLine("\nTop MIME types:");
foreach (var group in groupedByMime.Take(5))
{
Console.WriteLine($" {group.Key}: {group.Count()} definitions");
}
}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