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 } } }
internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler) { this.realPropertyInfo = propertyInfo; this.OnGetValue = getValueHandler; this.OnSetValue = setValueHandler; this.OnGetXmlQualifiedName = qualifiedNameHandler; }
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; }
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); }
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; }
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."); } }
/// <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."); } }
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; }
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); } }
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; }
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); }
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; }
/// <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) { }
internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler, WorkflowMarkupSerializationManager manager) : this(propertyInfo, getValueHandler, setValueHandler, qualifiedNameHandler) { this.manager = manager; }
private void Set(Control ctl, string key, string value) { svh = new SetValueHandler(SetControlValue); svh.Invoke(ctl, key, value); svh.Invoke(ctl, key, value); }
internal ChangeClosure(AccessContext parentContext, SetValueHandler action, string propertyName, object propertyValue) : base(parentContext) { _execute = action; _arg0 = propertyName; _arg1 = propertyValue; }
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 }); } } } }
public static Closure Create(AccessContext parentContext, SetValueHandler action,string propertyName, object propertyValue) { return new ChangeClosure(parentContext, action, propertyName, propertyValue); }
/// <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; }
private void Set(Control ctl, string key, string value) { svh = new SetValueHandler(SetControlValue); svh.Invoke(ctl,key,value); svh.Invoke(ctl, key, value); }
/// <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) { }
public CallbackAttacher(DataItemClient <T> source, SetValueHandler callback) { this.callback = callback; this.attacher = new DataItemAttacher <T>(this, source); }
public SimplePropertyDescriptor(string name, GetValueHandler getValueHandler, SetValueHandler setValueHandler, params Attribute[] attributes) : base(name, attributes) { this.getValueHandler = getValueHandler; this.setValueHandler = setValueHandler; }
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; }
public FieldHandler(FieldInfo field) { GetValue = ReflectionHandlerFactory.FieldGetHandler(field); SetValue = ReflectionHandlerFactory.FieldSetHandler(field); Field = field; }
/// <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) { }
/// <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) { }
public PropertyColor(Color defaultValue, String name, String group, String description, SetValueHandler <Color> setter, GetValueHandler <Color> getter) : base(defaultValue, name, group, description, setter, getter, "colorPicker") { }
/// <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; }
/// <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; }
/// <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; }
public static Closure Create(AccessContext parentContext, SetValueHandler action, string propertyName, object propertyValue) { return(new ChangeClosure(parentContext, action, propertyName, propertyValue)); }