-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathAlt.GlobalMeta.cs
More file actions
58 lines (48 loc) · 1.64 KB
/
Copy pathAlt.GlobalMeta.cs
File metadata and controls
58 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using AltV.Net.Elements.Args;
namespace AltV.Net
{
public static partial class Alt
{
public static void SetMetaData(string key, object value) => Core.SetMetaData(key, value);
public static bool HasMetaData(string key) => Core.HasMetaData(key);
public static void DeleteMetaData(string key) => Core.DeleteMetaData(key);
public static bool GetMetaData<T>(string key, out T result)
{
Core.GetMetaData(key, out var mValue);
using (mValue)
{
try
{
result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T));
return true;
}
catch
{
result = default;
return false;
}
}
}
public static void SetSyncedMetaData(string key, object value) => Core.SetSyncedMetaData(key, value);
public static bool HasSyncedMetaData(string key) => Core.HasSyncedMetaData(key);
public static void DeleteSyncedMetaData(string key) => Core.DeleteSyncedMetaData(key);
public static bool GetSyncedMetaData<T>(string key, out T result)
{
Core.GetSyncedMetaData(key, out var mValue);
using (mValue)
{
try
{
result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T));
return true;
}
catch
{
result = default;
return false;
}
}
}
}
}