public virtual void OnDataItemValueChanged(object sender, DataItemValue e) { if (!Loaded) { return; } if (sender == this) { return; } if (m_firstPublish) { return; } CheckForSetProperty(e); }
void component_DataItemValueSet(object sender, DataItemValue e) { DataItemValueSet.Fire(sender, e); }
public bool CheckForSetProperty(DataItemValue e) { // Call Methods if (m_propertyDictionary == null) { return(false); } if (m_propertyDictionary.Count == 0) { return(false); } if (!m_propertyDictionary.ContainsKey(e.Item.ID)) { return(false); } var property = m_propertyDictionary[e.Item.ID]; if (property == null) { return(false); } if (!property.PropertyInfo.CanWrite) { return(false); } object newProperty = null; try { if (e.Value == null) { return(false); } // get the current value object value = property.PropertyInfo.GetValue(property.Instance, null); // return if there's been no change if (value != null && value.ToString() == e.Value as string) { return(false); } if (property.PropertyInfo.PropertyType == typeof(double)) { // can't parse an empty string to a double // if(e.Value.IsNullOrEmpty()) return false; newProperty = e.Value; } else if (property.PropertyInfo.PropertyType == typeof(int)) { // can't parse an empty string to an int // if (e.Value.IsNullOrEmpty()) return false; newProperty = e.Value; } else if (property.PropertyInfo.PropertyType == typeof(string)) { newProperty = e.Value; } else if (property.PropertyInfo.PropertyType == typeof(bool)) { // can't parse an empty string to a bool // if (e.Value.IsNullOrEmpty()) return false; newProperty = e.Value; } else { // Unknown Type return(false); } property.PropertyInfo.SetValue(property.Instance, newProperty, null); return(true); } catch (Exception ex) { Debug.WriteLine("HostedAdapterBase::CheckForSetProperty Exception: " + ex.Message); return(false); } }
void DataItems_DataItemValueSet(object sender, DataItemValue e) { DataItemValueSet.Fire(sender, e); }