-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringId.cs
More file actions
21 lines (18 loc) · 824 Bytes
/
StringId.cs
File metadata and controls
21 lines (18 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using NapCatSharp.JsonConverter;
using System.Text.Json.Serialization;
namespace NapCatSharp;
/// <summary>
/// string型id
/// <br/> 拥有string -> long -> string的隐士类型转换
/// </summary>
[JsonConverter(typeof(StringIdConverter))]
public struct StringId
{
public string String;
public long Long;
public static implicit operator StringId(string string_) => new StringId { String = string_, Long = long.Parse(string_) };
public static implicit operator StringId(long long_) => new StringId { String = long_.ToString(), Long = long_ };
public static implicit operator string(StringId sid) => sid.String;
public static implicit operator long(StringId sid) => sid.Long;
public static implicit operator LongId(StringId sid) => new LongId{ String = sid.String, Long = sid.Long };
}