📦 AssetStatus Enum Documentation
Welcome to the comprehensive documentation for the AssetStatus enum in the IrbyImaging.Utility library. This document covers everything you need to know about the enum: its purpose, usage examples, dependencies, and even a UML diagram! 🎉
📑 Table of Contents
- Overview & Purpose
- Enum Definition & Members
- Dependencies & Technologies
- Key Functional Areas
- Usage Examples
- Helper Methods & Utilities
- UML Diagram
- Conclusion
1. Overview & Purpose 🎯
The AssetStatus enum represents the lifecycle state of an asset within the IrbyImaging system.
It is used throughout the business logic and UI layers to enforce consistency when referring to the status of physical or digital assets (e.g., cameras, devices, licenses).
2. Enum Definition & Members 🔍
// File: IrbyImaging.Utility/AssetStatus.cs
using System.ComponentModel.DataAnnotations;
namespace IrbyImaging.Utility
{
/// <summary>
/// Enum AssetStatus
/// Defines possible lifecycle states of an asset.
/// </summary>
public enum AssetStatus
{
/// <summary>The asset is currently active/in use.</summary>
Active,
/// <summary>The asset is ready and available.</summary>
Available,
/// <summary>The asset is lost or has been stolen.</summary>
[Display(Name = "Lost/Stolen")]
LostOrStolen,
/// <summary>The asset has been officially decommissioned.</summary>
Decommissioned,
/// <summary>The asset has been disposed of.</summary>
Disposed,
/// <summary>Represents all possible statuses.</summary>
All
}
}
2.1. Members Table
| Member | Display Name | Description |
|---|---|---|
| Active | Active | In active use |
| Available | Available | Ready for assignment/use |
| LostOrStolen | Lost/Stolen | Marked lost or stolen 🛑 |
| Decommissioned | Decommissioned | Officially taken out of service |
| Disposed | Disposed | Physically disposed of 🚮 |
| All | All | Wildcard representing every status |
3. Dependencies & Technologies 🔧
- .NET Standard / .NET Core / .NET Framework
- Namespace:
System.ComponentModel.DataAnnotations(for decoratingLostOrStolen) - Assembly:
IrbyImaging.BLUtility
No external NuGet packages are required for this enum itself.
4. Key Functional Areas 🚀
- Centralizes all possible asset statuses in one type-safe structure.
- Ensures compile-time checks (you cannot pass an invalid status).
- Works seamlessly with UI data-binding and serialization frameworks.
- Leverages
DisplayAttributefor human-friendly labels.
5. Usage Examples 💡
5.1 Basic Switch / Conditional Logic
void ProcessAsset(AssetStatus status)
{
switch (status)
{
case AssetStatus.Active:
Console.WriteLine("Asset is in use.");
break;
case AssetStatus.Available:
Console.WriteLine("Asset is ready for deployment.");
break;
case AssetStatus.LostOrStolen:
Console.WriteLine("Alert! Asset reported lost or stolen.");
break;
case AssetStatus.Decommissioned:
case AssetStatus.Disposed:
Console.WriteLine("Asset is no longer serviceable.");
break;
case AssetStatus.All:
Console.WriteLine("Select a specific status instead of 'All'.");
break;
}
}
5.2 Retrieving the Display Name
using System;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
public static class EnumExtensions
{
public static string GetDisplayName(this Enum enumValue)
{
return enumValue.GetType()
.GetMember(enumValue.ToString())[0]
.GetCustomAttribute<DisplayAttribute>()?
.GetName()
?? enumValue.ToString();
}
}
// Usage
Console.WriteLine(AssetStatus.LostOrStolen.GetDisplayName());
// Output: "Lost/Stolen"
5.3 JSON Serialization / Deserialization
Using System.Text.Json or Newtonsoft.Json, you can serialize enum values by name or numeric value:
// System.Text.Json (default: numeric)
var json = JsonSerializer.Serialize(AssetStatus.Active);
// json => "0"
// As string:
var options = new JsonSerializerOptions {
Converters = { new JsonStringEnumConverter() }
};
var jsonStr = JsonSerializer.Serialize(AssetStatus.Active, options);
// jsonStr => "\"Active\""
5.4 Binding to a .NET UI (e.g., ASP.NET)
In Razor Pages / MVC, you can bind the enum to a dropdown:
@model MyViewModel
@{
var statuses = Enum.GetValues(typeof(AssetStatus))
.Cast<AssetStatus>()
.Select(s => new SelectListItem {
Text = s.GetDisplayName(),
Value = s.ToString()
});
}
<select asp-for="SelectedStatus" asp-items="statuses"></select>
6. Helper Methods & Utilities 🤖
While the enum itself is simple, the DisplayAttribute opens the door to utilities:
GetDisplayName()extension method (see above).- Localization: decorate members with
[Display(Name = "...", ResourceType = typeof(Resources))]. - Validation: ensure form inputs which bind this enum only accept defined values.
7. UML Diagram 📊
Below is a PlantUML snippet illustrating the AssetStatus enum:
@startuml
enum AssetStatus {
Active
Available
LostOrStolen <<(D,#FF7700) [Display("Lost/Stolen")]>>
Decommissioned
Disposed
All
}
@enduml
(Replace with your own rendered UML if hosting locally.)
8. Conclusion ✅
The AssetStatus enum is a centralized, type-safe way to represent the state of assets across the IrbyImaging system. With minimal dependencies and powerful DataAnnotations support, it:
- Reduces magic strings throughout your code.
- Enables clear UI display via
[Display(Name=...)]. - Plays nicely with serialization frameworks.
Use AssetStatus whenever you need to track or present the current state of an imaging asset! 🎯
End of AssetStatus Documentation
Questions or feedback? Drop a comment or open an issue in the repo.