File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
src/BizHawk.Client.Common Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
2
4
3
5
namespace BizHawk . Client . Common
4
6
{
5
7
public sealed class UserDataApi : IUserDataApi
6
8
{
7
9
private readonly IMovieSession _movieSession ;
8
10
11
+ #if NET6_0
12
+ public IReadOnlySet < string > Keys
13
+ => throw new NotImplementedException ( ) ;
14
+ #else
15
+ public IReadOnlyCollection < string > Keys
16
+ => _movieSession . UserBag . Keys . ToList ( ) ;
17
+ #endif
18
+
9
19
public UserDataApi ( IMovieSession movieSession ) => _movieSession = movieSession ;
10
20
11
21
/// <exception cref="InvalidOperationException">type of <paramref name="value"/> cannot be used in userdata</exception>
Original file line number Diff line number Diff line change 1
- namespace BizHawk . Client . Common
1
+ using System . Collections . Generic ;
2
+
3
+ namespace BizHawk . Client . Common
2
4
{
3
5
public interface IUserDataApi : IExternalApi
4
6
{
7
+ #if NET6_0
8
+ IReadOnlySet < string > Keys { get ; }
9
+ #else
10
+ IReadOnlyCollection < string > Keys { get ; }
11
+ #endif
12
+
5
13
void Set ( string name , object value ) ;
6
14
object Get ( string key ) ;
7
15
void Clear ( ) ;
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . ComponentModel ;
3
4
5
+ using NLua ;
6
+
4
7
// ReSharper disable UnusedMember.Global
5
8
namespace BizHawk . Client . Common
6
9
{
@@ -37,5 +40,11 @@ public bool Remove([LuaArbitraryStringParam] string key)
37
40
[ LuaMethod ( "containskey" , "returns whether or not there is an entry for the given key" ) ]
38
41
public bool ContainsKey ( [ LuaArbitraryStringParam ] string key )
39
42
=> APIs . UserData . ContainsKey ( key ) ;
43
+
44
+ [ LuaMethodExample ( "console.writeline(#userdata.get_keys());" ) ]
45
+ [ LuaMethod ( "get_keys" , "returns a list-like table of valid keys" ) ]
46
+ [ return : LuaArbitraryStringParam ]
47
+ public LuaTable GetKeys ( )
48
+ => _th . ListToTable ( ( List < string > ) APIs . UserData . Keys ) ; //HACK cast will succeed as long as impl. returns Dictionary<K, V>.Keys.ToList() as IROC<K>
40
49
}
41
50
}
You can’t perform that action at this time.
0 commit comments