public SolidObject() { // Binding source is { this.properties.Add(BindingSourceProperty, new BindingSourceValue(this)); } foreach (var property in SolidProperty.GetProperties(this.GetType())) { if (property.Value == BindingSourceProperty) { continue; } this.properties.Add(property.Value, new PropertyValue(this, property.Value)); } }
/// <summary> /// Gets an object that stores and verifies a property value. /// </summary> /// <param name="property"></param> /// <returns></returns> private PropertyValue GetValueHolder(SolidProperty property) { lock (this.properties) { if (this.properties.ContainsKey(property)) { return(this.properties[property]); } throw new NotSupportedException("Late binding of properties is not supported."); /* * var value = new PropertyValue(this, property); * value.ValueChanged += Value_ValueChanged; * this.properties.Add(property, value); * return value; */ } }
public static SolidProperty Register( Type objectType, string name, Type propertyType, SolidPropertyMetadata metaData) { var property = new SolidProperty(name, objectType, propertyType, metaData ?? new SolidPropertyMetadata()); var registry = GetRegistryForType(objectType); lock (registry) { if (registry.ContainsKey(name)) { throw new InvalidOperationException($"The property {name} is already registered."); } registry.Add(name, property); } return(property); }
internal void SetPropertyBinding(SolidProperty property, string targetPropertyName) { var vh = GetValueHolder(property); vh.Binding = targetPropertyName; }
/// <summary> /// Gets the value of a SolidProperty. /// </summary> /// <param name="property"></param> /// <returns></returns> protected internal object Get(SolidProperty property) { var vh = GetValueHolder(property); return(vh.Value); }
/// <summary> /// Sets the value of a SolidProperty. /// </summary> /// <param name="property"></param> /// <param name="value"></param> protected internal void Set(SolidProperty property, object value) { var vh = GetValueHolder(property); vh.Value = value; }
public bool HasProperty(SolidProperty property) { return(this.properties.ContainsKey(property)); }
/// <summary> /// Gets a value of a SolidProperty. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="property"></param> /// <returns></returns> protected T Get <T>(SolidProperty property) => (T)Get(property);