Files
UnrealEngine/Engine/Source/Programs/Shared/EpicGames.Horde/Devices/DevicePoolId.cs
2025-05-18 13:04:45 +08:00

49 lines
1.4 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System.ComponentModel;
using EpicGames.Core;
using EpicGames.Serialization;
namespace EpicGames.Horde.Devices
{
/// <summary>
/// Identifier for a device pool
/// </summary>
/// <param name="Id">Id to construct from</param>
[LogValueType]
[JsonSchemaString]
[TypeConverter(typeof(StringIdTypeConverter<DevicePoolId, DevicePoolIdConverter>))]
[StringIdConverter(typeof(DevicePoolIdConverter))]
[CbConverter(typeof(StringIdCbConverter<DevicePoolId, DevicePoolIdConverter>))]
public readonly record struct DevicePoolId(StringId Id)
{
/// <summary>
/// Constructor
/// </summary>
public DevicePoolId(string id) : this(new StringId(id))
{
}
/// <inheritdoc cref="StringId.IsEmpty"/>
public bool IsEmpty => Id.IsEmpty;
/// <inheritdoc cref="StringId.Sanitize(System.String)"/>
public static DevicePoolId Sanitize(string text) => new DevicePoolId(StringId.Sanitize(text));
/// <inheritdoc/>
public override string ToString() => Id.ToString();
}
/// <summary>
/// Converter to and from <see cref="StringId"/> instances.
/// </summary>
class DevicePoolIdConverter : StringIdConverter<DevicePoolId>
{
/// <inheritdoc/>
public override DevicePoolId FromStringId(StringId id) => new DevicePoolId(id);
/// <inheritdoc/>
public override StringId ToStringId(DevicePoolId value) => value.Id;
}
}