53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace StgSharpDebug.Logic
|
|
{
|
|
#nullable enable
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate ref object BindingDataGetter();
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void BindingDataSetter(ref object value);
|
|
|
|
public unsafe struct DataBindingEntry
|
|
{
|
|
private IntPtr getterPtr, setterPtr;
|
|
|
|
public DataBindingEntry(
|
|
[NotNull] BindingDataGetter gettingCallback,
|
|
[NotNull] BindingDataSetter settingCallback)
|
|
{
|
|
getterPtr = Marshal.GetFunctionPointerForDelegate(gettingCallback);
|
|
setterPtr = Marshal.GetFunctionPointerForDelegate(settingCallback);
|
|
}
|
|
|
|
public ref object GetValue()
|
|
{
|
|
return ref ((delegate* unmanaged[Cdecl]<ref object>)getterPtr)();
|
|
}
|
|
|
|
public void SetData(ref object value)
|
|
{
|
|
((delegate* unmanaged[Cdecl]<ref object, void>)setterPtr)(ref value);
|
|
}
|
|
|
|
public static DataBindingEntry NullBinding
|
|
{
|
|
get => new DataBindingEntry();
|
|
}
|
|
|
|
public bool ExactEqual(DataBindingEntry other)
|
|
{
|
|
return getterPtr == other.getterPtr && setterPtr == other.setterPtr;
|
|
}
|
|
}
|
|
|
|
#nullable restore
|
|
}
|