You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

14 lines
358 B

using System.Collections.Generic;
namespace gaemstone.Utility;
public static class CallbackContextHelper
{
private static readonly List<object> _contexts = new();
public static nint Create<T>(T context) where T : notnull
{ _contexts.Add(context); return _contexts.Count; }
public static T Get<T>(nint context)
=> (T)_contexts[(int)context - 1];
}