/// <summary> /// Assign a value to a property given its name. /// </summary> /// <param name="propertyName">Name of property to set</param> /// <param name="val">Value to assign to property</param> /// <remarks> /// This method will add the property to the container if it doesn't /// already exist. /// </remarks> public override void SetPropertyValue(string propertyName, object val) { if (propertyName == "Text") { this.text = (string)val; } else if (propertyName == "ContainerName") { if (this.container != null) { IPropertyContainer propContainer = this.container.GetService(typeof(IPropertyContainer)) as IPropertyContainer; if (propContainer != null) { propContainer.SetPropertyValue("Name", val); } } } else { if (this.propertyValues.ContainsKey(propertyName)) { this.propertyValues[propertyName] = val; } else { this.propertyValues.Add(propertyName, val); } } }
/// <summary> /// Helper. /// </summary> void SetObjectPropertyValueByTag(object tag, object value) { if (tag is string) {// This is a dynamic generic property. _selectedObject.SetPropertyValue(tag as string, value); } else if (tag is PropertyInfo) {// Direct property of the indicator. ((PropertyInfo)tag).SetValue(_selectedObject, value, null); } else { //SystemMonitor.Error("Unrecognized tag type for indicator property."); } _selectedObject.PropertyChanged(); }