private protected override void InitializeByRef(PropertyInfo propertyInfo, XBindingFlags flags) { base.InitializeByRef(propertyInfo, flags); declaringType = propertyInfo.DeclaringType; if (_get == null || _set == null) { var getMethod = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0); if (getMethod != null) { var _ref = MethodHelper.CreateDelegate <XStructRefValueHandler <TStruct, TValue> >(getMethod, false); _get = (ref TStruct obj) => { return(_ref(ref obj)); }; _set = (ref TStruct obj, TValue value) => { _ref(ref obj) = value; }; } } }
private protected override void InitializeByValue(PropertyInfo propertyInfo, XBindingFlags flags) { base.InitializeByValue(propertyInfo, flags); declaringType = propertyInfo.DeclaringType; if (_get == null) { var getMethod = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0); if (getMethod != null) { _get = MethodHelper.CreateDelegate <XStructGetValueHandler <TStruct, TValue> >(getMethod, false); } } if (_set == null) { var setMethod = propertyInfo.GetSetMethod((flags & XBindingFlags.NonPublic) != 0); if (setMethod != null) { _set = MethodHelper.CreateDelegate <XStructSetValueHandler <TStruct, TValue> >(setMethod, false); } } }
internal override void Initialize(PropertyInfo propertyInfo, XBindingFlags flags) { base.Initialize(propertyInfo, flags); declaringType = propertyInfo.DeclaringType; var getMethod = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0); var setMethod = propertyInfo.GetSetMethod((flags & XBindingFlags.NonPublic) != 0); if (getMethod != null) { _get = MethodHelper.CreateDelegate <XStructGetValueHandler <TStruct, TValue> >(getMethod, SignatureLevels.Cast); } if (setMethod != null) { _set = MethodHelper.CreateDelegate <XStructSetValueHandler <TStruct, TValue> >(setMethod, SignatureLevels.Cast); } }
private protected override void InitializeByValue(PropertyInfo propertyInfo, XBindingFlags flags) { base.InitializeByValue(propertyInfo, flags); if ((flags & XBindingFlags.RWAutoPropertyDirectRW) != 0 && TypeHelper.IsAutoProperty(propertyInfo, out var fieldInfo) && fieldInfo != null) { try { var offset = TypeHelper.OffsetOf(fieldInfo); _get = (ref TStruct obj) => Underlying.AddByteOffset(ref Underlying.As <TStruct, TValue>(ref obj), offset); _set = (ref TStruct obj, TValue value) => Underlying.AddByteOffset(ref Underlying.As <TStruct, TValue>(ref obj), offset) = value; return; } catch { } } if (_get is null) { var getMethod = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0); if (getMethod != null) { _get = MethodHelper.CreateDelegate <XStructGetValueHandler <TStruct, TValue> >(getMethod, false); } } if (_set is null) { var setMethod = propertyInfo.GetSetMethod((flags & XBindingFlags.NonPublic) != 0); if (setMethod != null) { _set = MethodHelper.CreateDelegate <XStructSetValueHandler <TStruct, TValue> >(setMethod, false); } } }
internal override void InitializeByRef(PropertyInfo propertyInfo, XBindingFlags flags) { base.InitializeByRef(propertyInfo, flags); declaringTypeHandle = TypeHelper.GetTypeHandle(propertyInfo.DeclaringType); var getMethod = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0); if (getMethod != null) { var _ref = MethodHelper.CreateDelegate <XStructRefValueHandler <TStruct, TValue> >(getMethod, SignatureLevels.Cast); _get = (ref TStruct obj) => { return(_ref(ref obj)); }; _set = (ref TStruct obj, TValue value) => { _ref(ref obj) = value; }; } }