Beispiel #1
0
        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;
                    };
                }
            }
        }
Beispiel #2
0
        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);
                }
            }
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        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);
                }
            }
        }
Beispiel #5
0
        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;
                };
            }
        }