daily update on 20240901 by nitload youmu
This commit is contained in:
@@ -28,13 +28,16 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Data;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -45,10 +48,40 @@ namespace StgSharp.MVVM.ViewModel
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate ref object BindingDataGetter();
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void BindingDataSetter(ref object value);
|
||||
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
public bool MethodLookup(string methodName, out Action callback)
|
||||
{
|
||||
MethodInfo method = GetType().GetMethod(methodName);
|
||||
try
|
||||
{
|
||||
callback = (Action)Delegate.CreateDelegate(typeof(Action), this, methodName);
|
||||
return true;
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
catch (MethodAccessException)
|
||||
{
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public unsafe struct DataBindingEntry
|
||||
{
|
||||
|
||||
private IntPtr getterPtr, setterPtr;
|
||||
[FieldOffset(0)] private M128 _mask;
|
||||
[FieldOffset(0)] private IntPtr getterPtr;
|
||||
[FieldOffset(8)] private IntPtr setterPtr;
|
||||
|
||||
public DataBindingEntry(
|
||||
[NotNull] BindingDataGetter gettingCallback,
|
||||
@@ -73,11 +106,39 @@ namespace StgSharp.MVVM.ViewModel
|
||||
return ref ((delegate* unmanaged[Cdecl]<ref object>)getterPtr)();
|
||||
}
|
||||
|
||||
public void SetData(ref object value)
|
||||
public void SetValue(ref object value)
|
||||
{
|
||||
((delegate* unmanaged[Cdecl]<ref object, void>)setterPtr)(ref value);
|
||||
}
|
||||
|
||||
public static bool operator ==(DataBindingEntry left, DataBindingEntry right)
|
||||
{
|
||||
return left._mask == right._mask;
|
||||
}
|
||||
|
||||
public static bool operator !=(DataBindingEntry left, DataBindingEntry right)
|
||||
{
|
||||
return left._mask != right._mask;
|
||||
}
|
||||
|
||||
public bool Equals(DataBindingEntry other)
|
||||
{
|
||||
return (_mask == other._mask);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is not DataBindingEntry other)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _mask.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#nullable restore
|
||||
|
||||
Reference in New Issue
Block a user