/// <inheritdoc/> internal override IDisposable?RouteSetValue( AvaloniaObject o, object?value, BindingPriority priority) { var v = TryConvert(value); if (v.HasValue) { o.SetValue <TValue>(this, (TValue)v.Value !); } else if (v.Type == BindingValueType.UnsetValue) { o.ClearValue(this); } else if (v.HasError) { throw v.Error !; } return(null); }
internal abstract void RouteInheritanceParentChanged(AvaloniaObject o, IAvaloniaObject oldParent);
public ValueStore(AvaloniaObject owner) { _sink = _owner = owner; _values = new AvaloniaPropertyValueStore <IValue>(); }
/// <inheritdoc/> internal override void RouteInheritanceParentChanged( AvaloniaObject o, IAvaloniaObject?oldParent) { o.InheritanceParentChanged(this, oldParent); }
/// <summary> /// Gets all <see cref="AvaloniaProperty"/>s registered on a object. /// </summary> /// <param name="o">The object.</param> /// <returns>A collection of <see cref="AvaloniaProperty"/> definitions.</returns> public IEnumerable <AvaloniaProperty> GetRegistered(AvaloniaObject o) { Contract.Requires <ArgumentNullException>(o != null); return(GetRegistered(o.GetType())); }
/// <summary> /// Finds a registered property on an object by name. /// </summary> /// <param name="o">The object.</param> /// <param name="name"> /// The property name. If an attached property it should be in the form /// "OwnerType.PropertyName". /// </param> /// <returns> /// The registered property or null if no matching property found. /// </returns> public AvaloniaProperty FindRegistered(AvaloniaObject o, string name) { return(FindRegistered(o.GetType(), name)); }
internal override void RouteInheritanceParentChanged(AvaloniaObject o, IAvaloniaObject oldParent) { throw new NotSupportedException("Direct properties do not support inheritance."); }
/// <inheritdoc/> internal override object?RouteGetValue(AvaloniaObject o) { return(o.GetValue <TValue>(this)); }
internal override object?RouteGetBaseValue(AvaloniaObject o, BindingPriority maxPriority) { return(o.GetValue <TValue>(this)); }
/// <inheritdoc/> internal override void RouteClearValue(AvaloniaObject o) { o.ClearValue <TValue>(this); }
internal void NotifyInitialized(AvaloniaObject o) { Contract.Requires <ArgumentNullException>(o != null); var type = o.GetType(); void Notify(AvaloniaProperty property, object value) { var e = new AvaloniaPropertyChangedEventArgs( o, property, AvaloniaProperty.UnsetValue, value, BindingPriority.Unset); property.NotifyInitialized(e); } if (!_initializedCache.TryGetValue(type, out var initializationData)) { var visited = new HashSet <AvaloniaProperty>(); initializationData = new List <PropertyInitializationData>(); foreach (AvaloniaProperty property in GetRegistered(type)) { if (property.IsDirect) { initializationData.Add(new PropertyInitializationData(property, (IDirectPropertyAccessor)property)); } else { initializationData.Add(new PropertyInitializationData(property, (IStyledPropertyAccessor)property, type)); } visited.Add(property); } foreach (AvaloniaProperty property in GetRegisteredAttached(type)) { if (!visited.Contains(property)) { initializationData.Add(new PropertyInitializationData(property, (IStyledPropertyAccessor)property, type)); visited.Add(property); } } _initializedCache.Add(type, initializationData); } foreach (PropertyInitializationData data in initializationData) { if (!data.Property.HasNotifyInitializedObservers) { continue; } object value = data.IsDirect ? data.DirectAccessor.GetValue(o) : data.Value; Notify(data.Property, value); } }
public ValueStore(AvaloniaObject owner) { _owner = owner; }
/// <inheritdoc/> internal override object?RouteGetBaseValue(AvaloniaObject o, BindingPriority maxPriority) { var value = o.GetBaseValue <TValue>(this, maxPriority); return(value.HasValue ? value.Value : AvaloniaProperty.UnsetValue); }
public ValueStore(AvaloniaObject owner) { _owner = owner; _propertyValues = new AvaloniaPropertyValueStore<object>(); _deferredSetters = new AvaloniaPropertyValueStore<object>(); }