コード例 #1
0
        private protected override void InitializeByRef(PropertyInfo propertyInfo, XBindingFlags flags)
        {
            base.InitializeByRef(propertyInfo, flags);

            if (_get is null || _set is null)
            {
                var getMethod = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0);

                if (getMethod != null)
                {
                    var _ref = (RefValueHandler)Delegate.CreateDelegate(typeof(RefValueHandler), getMethod);

                    _get = (ref TStruct obj) =>
                    {
                        return(_ref(ref obj));
                    };

                    _set = (ref TStruct obj, TValue value) =>
                    {
                        _ref(ref obj) = value;
                    };

                    // TODO: AOTCheck
                }
            }
        }
コード例 #2
0
 internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler)
 {
     this.realPropertyInfo = propertyInfo;
     this.OnGetValue = getValueHandler;
     this.OnSetValue = setValueHandler;
     this.OnGetXmlQualifiedName = qualifiedNameHandler;
 }
コード例 #3
0
 internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler)
 {
     this.realPropertyInfo      = propertyInfo;
     this.OnGetValue            = getValueHandler;
     this.OnSetValue            = setValueHandler;
     this.OnGetXmlQualifiedName = qualifiedNameHandler;
 }
コード例 #4
0
        protected virtual void AddProperty(string propertyName,
                                           string description,
                                           GetValueHandler getValueHandler,
                                           SetValueHandler setValueHandler,
                                           ValidateEnableHandler isEnableHandler,
                                           ValidateVisibleHandler isVisibleHandler,
                                           ValidateValueHandler validateHandler)
        {
            BOProperty property = new BOProperty(
                propertyName,
                description,
                getValueHandler,
                setValueHandler,
                isEnableHandler,
                isVisibleHandler,
                validateHandler
                );

            if (mProperties.ContainsKey(propertyName))
            {
                throw new Exception(string.Format("property {0} already exists", propertyName));
            }

            mProperties[propertyName] = property;
        }
コード例 #5
0
        private static SetValueHandler CreatePropertySetHandler(PropertyInfo property)
        {
            DynamicMethod dynamicMethod = new DynamicMethod(string.Empty, null, new Type[] { typeof(object), typeof(object) }, property.DeclaringType.Module);

            ILGenerator ilGenerator = dynamicMethod.GetILGenerator();


            ilGenerator.Emit(OpCodes.Ldarg_0);


            ilGenerator.Emit(OpCodes.Ldarg_1);


            EmitCastToReference(ilGenerator, property.PropertyType);


            ilGenerator.EmitCall(OpCodes.Callvirt, property.GetSetMethod(), null);


            ilGenerator.Emit(OpCodes.Ret);


            SetValueHandler setter = (SetValueHandler)dynamicMethod.CreateDelegate(typeof(SetValueHandler));

            return(setter);
        }
コード例 #6
0
ファイル: PropertyAnimation.cs プロジェクト: drme/thw-ui
 public LinearPropertyAnimation(int startValue, int endValue, double duration, SetValueHandler<int> propertySetter)
 {
     this.animating = (startValue != endValue);
     this.startPos = startValue;
     this.endPos = endValue;
     this.animationTime = (int)(duration * 1000);
     this.animationTimeElapsed = 0;
     this.propertySetter = propertySetter;
 }
コード例 #7
0
        public void SetClrValue(object instance, object?clrValue)
        {
            if (SetValueHandler != null)
            {
                Debug.Assert(clrValue != DBNull.Value);

                SetValueHandler.Invoke(instance, clrValue);
            }
            else
            {
                throw new MicroOrmException($"Property '{PropertyName}' is not writable.");
            }
        }
コード例 #8
0
        /// <param name="sqlRawValue">Может быть <see cref="DBNull"/>.</param>
        /// <param name="sqlColumnName">Используется только для ошибок.</param>
        public void ConvertAndSetValue(object instance, object sqlRawValue, Type sqlColumnType, string sqlColumnName)
        {
            if (SetValueHandler != null)
            {
                object?clrValue = ConvertSqlToClrValue(sqlRawValue, sqlColumnType, sqlColumnName);

                SetValueHandler.Invoke(instance, clrValue);
            }
            else
            {
                throw new MicroOrmException($"Property '{PropertyName}' is not writable.");
            }
        }
コード例 #9
0
ファイル: PropertyHandler.cs プロジェクト: smuki/Light.Data2
 public PropertyHandler(PropertyInfo property)
 {
     if (property.CanWrite)
     {
         this.mSetValue = ReflectionHandlerFactory.PropertySetHandler(property);
     }
     if (property.CanRead)
     {
         this.mGetValue = ReflectionHandlerFactory.PropertyGetHandler(property);
     }
     this.mProperty     = property;
     this.IndexProperty = this.mProperty.GetMethod.GetParameters().Length > 0;
 }
コード例 #10
0
        public PropertyAccessor(Type ownerType, string propertyName)
        {
            PropertyInfo propertyInfo = ownerType.GetProperty(propertyName);

            if (propertyInfo.CanRead)
            {
                this._getValueHandler = this.CreateGetValueHandler(propertyInfo);
            }

            if (propertyInfo.CanWrite)
            {
                this._setValueHandler = this.CreateSetValueHandler(propertyInfo);
            }
        }
コード例 #11
0
 public BOProperty(
     string propertyName,
     string description,
     GetValueHandler getValueHandler,
     SetValueHandler setValueHandler,
     ValidateEnableHandler isEnableHandler,
     ValidateVisibleHandler isVisibleHandler,
     ValidateValueHandler validateValueHandler
     )
 {
     this.Description             = description;
     this.PropertyName            = propertyName;
     this.mGetValueHandler        = getValueHandler;
     this.mSetValueHandler        = setValueHandler;
     this.mValidateEnableHandler  = isEnableHandler;
     this.mValidateVisibleHandler = isVisibleHandler;
     this.mValidateValueHandler   = validateValueHandler;
 }
コード例 #12
0
ファイル: BluetoothLECar.cs プロジェクト: sengeiou/drme
        private async Task <GattCharacteristic> GetCharacteristics(ushort id, SetValueHandler setter)
        {
            var characteristic = GetCharacteristicObject(id);

            if ((null != characteristic) && (null != setter))
            {
                GattReadResult readResult = await characteristic.ReadValueAsync();

                if (readResult.Status == GattCommunicationStatus.Success)
                {
                    byte[] sensorData = new byte[readResult.Value.Length];
                    DataReader.FromBuffer(readResult.Value).ReadBytes(sensorData);

                    setter(BitConverter.ToUInt16(sensorData, 0));
                }
            }

            return(characteristic);
        }
コード例 #13
0
        public DataParameterMapping(PropertyInfo property, string name, ParameterDirection direction)
        {
            if (property.CanRead)
            {
                this.mGetValue = ReflectionHandlerFactory.PropertyGetHandler(property);
            }
            if (property.CanWrite)
            {
                this.mSetValue = ReflectionHandlerFactory.PropertySetHandler(property);
            }
            this.mType = property.PropertyType;
            TypeCode code = Type.GetTypeCode(this.mType);

            this.mConvertString = code == TypeCode.Object || code == TypeCode.DBNull || code == TypeCode.Empty;
            if ((this.mDirection == ParameterDirection.InputOutput || this.mDirection == ParameterDirection.Output) && mConvertString)
            {
                throw new LightDataException(SR.OutputParameterNotSupportObjectType);
            }
            this.mProperty  = property;
            this.mName      = string.IsNullOrEmpty(name) ? property.Name : name;
            this.mDirection = direction;
        }
コード例 #14
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyInteger(int defaultValue, String name, String group, String description, SetValueHandler <int> setter, GetValueHandler <int> getter) :  base(defaultValue, name, group, description, setter, getter, TextBox.TypeName)
 {
 }
コード例 #15
0
 internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler, WorkflowMarkupSerializationManager manager) : this(propertyInfo, getValueHandler, setValueHandler, qualifiedNameHandler)
 {
     this.manager = manager;
 }
コード例 #16
0
ファイル: main.cs プロジェクト: qq858187064/12306
 private void Set(Control ctl, string key, string value)
 {
     svh = new SetValueHandler(SetControlValue);
     svh.Invoke(ctl, key, value);
     svh.Invoke(ctl, key, value);
 }
コード例 #17
0
 internal ChangeClosure(AccessContext parentContext, SetValueHandler action, string propertyName, object propertyValue) : base(parentContext)
 {
     _execute = action;
     _arg0    = propertyName;
     _arg1    = propertyValue;
 }
コード例 #18
0
        private protected override void InitializeByValue(PropertyInfo propertyInfo, XBindingFlags flags)
        {
            base.InitializeByValue(propertyInfo, flags);

            if ((flags & XBindingFlags.RWAutoPropertyDirectRW) != 0 /* || !VersionDifferences.IsSupportEmit */)
            {
                if (TypeHelper.IsAutoProperty(propertyInfo, out var fieldInfo) && fieldInfo != null)
                {
                    try
                    {
                        var offset = TypeHelper.OffsetOf(fieldInfo);

                        _get = (obj) => Underlying.AddByteOffset(ref TypeHelper.Unbox <TValue>(obj), offset);
                        _set = (obj, value) => Underlying.AddByteOffset(ref TypeHelper.Unbox <TValue>(obj), offset) = value;

                        return;
                    }
                    catch
                    {
                    }
                }
            }

            if (_get is null)
            {
                var getMethod = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0);

                if (getMethod != null)
                {
                    var __get = (GetValueHandler)Delegate.CreateDelegate(typeof(GetValueHandler), getMethod);

                    _get = VersionDifferences.IsSupportEmit ? __get : AOTCheck;

                    TValue AOTCheck(TClass obj)
                    {
                        try
                        {
                            return(__get(obj));
                        }
                        catch (ExecutionEngineException)
                        {
                            __get = AOT;

                            return(AOT(obj));
                        }
                        finally
                        {
                            _get = __get;
                        }
                    }

                    TValue AOT(TClass obj)
                    {
                        return((TValue)getMethod.Invoke(obj, null));
                    }
                }
            }

            if (_set is null)
            {
                var setMethod = propertyInfo.GetSetMethod((flags & XBindingFlags.NonPublic) != 0);

                if (setMethod != null)
                {
                    var __set = (SetValueHandler)Delegate.CreateDelegate(typeof(SetValueHandler), setMethod);

                    _set = VersionDifferences.IsSupportEmit ? __set : AOTCheck;

                    void AOTCheck(TClass obj, TValue value)
                    {
                        try
                        {
                            __set(obj, value);
                        }
                        catch (ExecutionEngineException)
                        {
                            __set = AOT;

                            AOT(obj, value);
                        }
                        finally
                        {
                            _set = __set;
                        }
                    }

                    void AOT(TClass obj, TValue value)
                    {
                        setMethod.Invoke(obj, new object[] { value });
                    }
                }
            }
        }
コード例 #19
0
ファイル: Closures.cs プロジェクト: netintellect/NetOffice
 public static Closure Create(AccessContext parentContext, SetValueHandler action,string propertyName, object propertyValue)
 {
     return new ChangeClosure(parentContext, action, propertyName, propertyValue);
 }
コード例 #20
0
ファイル: PropertyImage.cs プロジェクト: drme/thw-ui
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyImage(String currentValue, String name, String group, String description, SetValueHandler<String> setter, GetValueHandler<String> getter)
     : base(currentValue, name, group, description, setter, getter)
 {
     this.ControlType = FilePicker.TypeName;
 }
コード例 #21
0
ファイル: main.cs プロジェクト: wings9119/12306
 private void Set(Control ctl, string key, string value)
 {
     svh = new SetValueHandler(SetControlValue);
     svh.Invoke(ctl,key,value);
     svh.Invoke(ctl, key, value);
 }
コード例 #22
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyAnchor(AnchorStyle defaultValue, String name, String group, String description, SetValueHandler <AnchorStyle> setter, GetValueHandler <AnchorStyle> getter) : base(defaultValue, name, group, description, setter, getter, AnchorPicker.TypeName)
 {
 }
コード例 #23
0
 public CallbackAttacher(DataItemClient <T> source, SetValueHandler callback)
 {
     this.callback = callback;
     this.attacher = new DataItemAttacher <T>(this, source);
 }
コード例 #24
0
 public SimplePropertyDescriptor(string name, GetValueHandler getValueHandler, SetValueHandler setValueHandler, params Attribute[] attributes) : base(name, attributes)
 {
     this.getValueHandler = getValueHandler;
     this.setValueHandler = setValueHandler;
 }
コード例 #25
0
ファイル: PropertyAnimation.cs プロジェクト: drme/thw-ui
 public LinearPropertyAnimation(int startValue, int endValue, double duration, SetValueHandler <int> propertySetter)
 {
     this.animating            = (startValue != endValue);
     this.startPos             = startValue;
     this.endPos               = endValue;
     this.animationTime        = (int)(duration * 1000);
     this.animationTimeElapsed = 0;
     this.propertySetter       = propertySetter;
 }
コード例 #26
0
ファイル: EmitHandler.cs プロジェクト: judypol/JordyLibary
 public FieldHandler(FieldInfo field)
 {
     GetValue = ReflectionHandlerFactory.FieldGetHandler(field);
     SetValue = ReflectionHandlerFactory.FieldSetHandler(field);
     Field    = field;
 }
コード例 #27
0
 internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler, WorkflowMarkupSerializationManager manager)
     : this(propertyInfo, getValueHandler, setValueHandler, qualifiedNameHandler)
 {
     this.manager = manager;
 }
コード例 #28
0
ファイル: Closures.cs プロジェクト: netintellect/NetOffice
 internal ChangeClosure(AccessContext parentContext, SetValueHandler action, string propertyName, object propertyValue) : base(parentContext)
 {
     _execute = action;
     _arg0 = propertyName;
     _arg1 = propertyValue;
 }
コード例 #29
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyBoolean(bool defaultValue, String name, String group, String description, SetValueHandler <bool> setter, GetValueHandler <bool> getter) : base(defaultValue, name, group, description, setter, getter, ComboBox.TypeName)
 {
 }
コード例 #30
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyList(ListType defaultValue, String name, String group, String description, SetValueHandler <ListType> setter, GetValueHandler <ListType> getter) : base(defaultValue, name, group, description, setter, getter, ComboBox.TypeName)
 {
 }
コード例 #31
0
ファイル: PropertyColor.cs プロジェクト: drme/thw-ui
 public PropertyColor(Color defaultValue, String name, String group, String description, SetValueHandler <Color> setter, GetValueHandler <Color> getter) : base(defaultValue, name, group, description, setter, getter, "colorPicker")
 {
 }
コード例 #32
0
ファイル: PropertyFont.cs プロジェクト: drme/thw-ui
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="engine">ui engine for enumerating available fonts list.</param>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyFont(UIEngine engine, String defaultValue, String name, String group, String description, SetValueHandler <String> setter, GetValueHandler <String> getter) : base(defaultValue, name, group, description, setter, getter)
 {
     this.engine      = engine;
     this.ControlType = TextBox.TypeName;
 }
コード例 #33
0
ファイル: PropertyImage.cs プロジェクト: drme/thw-ui
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyImage(String currentValue, String name, String group, String description, SetValueHandler <String> setter, GetValueHandler <String> getter) : base(currentValue, name, group, description, setter, getter)
 {
     this.ControlType = FilePicker.TypeName;
 }
コード例 #34
0
ファイル: PropertyFont.cs プロジェクト: drme/thw-ui
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="engine">ui engine for enumerating available fonts list.</param>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyFont(UIEngine engine, String defaultValue, String name, String group, String description, SetValueHandler<String> setter, GetValueHandler<String> getter)
     : base(defaultValue, name, group, description, setter, getter)
 {
     this.engine = engine;
     this.ControlType = TextBox.TypeName;
 }
コード例 #35
0
 public static Closure Create(AccessContext parentContext, SetValueHandler action, string propertyName, object propertyValue)
 {
     return(new ChangeClosure(parentContext, action, propertyName, propertyValue));
 }