public static TRet Create <TRet>(out T value, Func <OutputAccessor <T>, TRet> func) { return(SafeReference.CreateOut( out value, r => func(new OutputAccessor <T>(r)) )); }
public static void Create(out T value, Action <OutputAccessor <T> > act) { SafeReference.CreateOut( out value, r => act(new OutputAccessor <T>(r)) ); }
public static TRet Create <TRet>(ref T value, Func <ReferenceAccessor <T>, TRet> func) { return(SafeReference.Create( ref value, r => func(new ReferenceAccessor <T>(r)) )); }
public static void Create(ref T value, Action <ReferenceAccessor <T> > act) { SafeReference.Create( ref value, r => act(new ReferenceAccessor <T>(r)) ); }
public TRet GetReference <TRet>(int index, Func <SafeReference, TRet> func) { if (index < 0 || index >= count) { throw new ArgumentOutOfRangeException("index"); } return(SafeReference.Create(ref _items[index], func)); }
/// <summary> /// Pins a reference in a memory and constructs its pin handle. /// </summary> /// <param name="r">The reference to pin.</param> protected void ReferenceAction(SafeReference r) { using (var re1 = new AutoResetEvent(false)) { var thr = new Thread( delegate() { r.GetReference( //References are thread-unsafe! tr => { #if STORE_REFERENCE { SafeReference.Create( tr, r2 => { Reference = r2; re1.Set(); Reset.WaitOne(); } ); } #else { tr.Pin( delegate { re1.Set(); Reset.WaitOne(); } ); } #endif } ); } ); thr.Start(); re1.WaitOne(); } }
public static void SetValueDirect(this FieldInfo fi, SafeReference sr, object value) { sr.GetReference(tr => fi.SetValueDirect(tr, value)); }
public ReferenceAccessor(SafeReference r) : base(r) { }
/// <summary> /// Changes the address of a <see cref="SafeReference"/>. /// </summary> /// <param name="target">The target reference.</param> /// <param name="addr">The new address.</param> public static void ChangeAddress(SafeReference target, IntPtr addr) { target.ChangeAddress(addr); }
/// <summary> /// Returns the address of a <see cref="SafeReference"/>. /// </summary> /// <param name="target">The target reference.</param> /// <returns>The address of the reference.</returns> public static IntPtr GetAddress(SafeReference target) { return(target.GetAddress()); }
// I wonder if it's necessary not to return the actual pointer, since these functions // don't attempt to pin the reference at all. I am not sure if the CLR would move it. /// <summary> /// Changes the type of a <see cref="SafeReference"/> to a new one. /// </summary> /// <param name="target">The target reference.</param> /// <param name="newType">The new type of the reference.</param> public static unsafe void ChangeType(SafeReference target, Type newType) { target.ChangeType(newType); }
public static TField GetValueDirect <TField>(this FieldInfo fi, SafeReference sr) { return(sr.GetReference(tr => GetValueDirect <TField>(fi, tr))); }
public TRet GetReference <TRet>(Func <SafeReference, TRet> func) { return(SafeReference.GetBoxedReference(Instance, func)); }
public TRet GetTempReference <TRet>(Func <SafeReference, TRet> func) { return(GetTempReference(tr => SafeReference.Create(tr, func))); }
public TRet GetReference <TRet>(Func <SafeReference, TRet> func) { return(TypedReferenceTools.MakeTypedReference(Target, new[] { Field }, tr => SafeReference.Create(tr, func))); }
public TRet GetReference <TRet>(Func <SafeReference, TRet> func) { return(SafeReference.Create(__makeref(Array[Index]), func)); }
/// <summary> /// Pins a reference in a memory and constructs its pin handle. /// </summary> /// <param name="obj">The reference to pin.</param> public OutPinHandle(out T obj) { SafeReference.CreateOut(out obj, ReferenceAction); }
/// <summary> /// Pins a reference in a memory and constructs its pin handle. /// </summary> /// <param name="obj">The reference to pin.</param> public RefPinHandle(ref T obj) { SafeReference.Create(ref obj, ReferenceAction); }
public OutputAccessor(SafeReference r) { Ref = r; }
/// <summary> /// Obtains a reference to an element in this array. /// </summary> public TRet GetReference <TRet>(int index, Func <SafeReference, TRet> func) { return(SafeReference.Create(ref array[index].Value, func)); }
public static object GetValueDirect(this FieldInfo fi, SafeReference sr) { return(sr.GetReference(tr => fi.GetValueDirect(tr))); }
public void GetTempReference(Action <SafeReference> act) { GetTempReference(tr => SafeReference.Create(tr, act)); }
public static void SetValueDirect <TField>(this FieldInfo fi, SafeReference sr, TField value) { sr.GetReference(tr => SetValueDirect <TField>(fi, tr, value)); }
public TypedContainer(SafeReference sr) : this() { Type = sr.Type; Value = sr.Value; }
public TRet GetReference <TRet>(Func <SafeReference, TRet> func) { return(SafeReference.Create(__makeref(Value), func)); }