public CompositeObjectProperty GetVirtualProperty(Type t, CompositeObjectProperty p) { if (!IsPropertyAvailable(t, p)) { throw new KeyNotFoundException(); } return(GetProperties(t).First(prop => prop.PropName == p.PropName)); }
public void SetValue(CompositeObject owner, CompositeObjectProperty prop, IPropertyValue value) { Dictionary <CompositeObjectProperty, IPropertyValue> props; if (!_valueStorage.TryGetValue(owner, out props)) { props = new Dictionary <CompositeObjectProperty, IPropertyValue>(); _valueStorage.Add(owner, props); } var oldValue = props[prop]; props[prop] = value; oldValue.OnDetached(owner, prop); value.OnAttached(owner, prop); }
public void RegisterProperty <TOwner>(CompositeObjectProperty property) { var t = typeof(TOwner); if (_registeredProperties.TryGetValue(t, out var list)) { list.Add(property); } else { list = new List <CompositeObjectProperty>() { property }; _registeredProperties.Add(t, list); } }
public bool IsPropertyAvailable(Type tOwner, CompositeObjectProperty property) { bool available = _registeredProperties.TryGetValue(tOwner, out var props) && props.Contains(property); if (property.Metadata.Options.HasFlag(PropertyOptions.Inherits)) { var t = tOwner.BaseType; while (!available && t is not null) { available = _registeredProperties.TryGetValue(t, out props) && props.Contains(property); t = t.BaseType; } } return(available); }
public void OnDetached(CompositeObject owner, CompositeObjectProperty prop) { Detached?.Invoke(owner, prop); }
public void OnChanged(CompositeObject owner, CompositeObjectProperty prop) { Changed?.Invoke(owner, prop); }
public bool IsSet(CompositeObject obj, CompositeObjectProperty prop) { return(_valueStorage[obj][prop] is not UnsetValue); }
public IPropertyValue GetValue(CompositeObject owner, CompositeObjectProperty prop) { return(_valueStorage[owner][prop]); }