protected virtual void AddProperty(string propertyName, string description, GetValueHandler getValueHandler, SetValueHandler setValueHandler, ValidateEnableHandler isEnableHandler, ValidateVisibleHandler isVisibleHandler, ValidateValueHandler validateHandler) { BOProperty property = new BOProperty( propertyName, description, getValueHandler, setValueHandler, isEnableHandler, isVisibleHandler, validateHandler ); if (mProperties.ContainsKey(propertyName)) { throw new Exception(string.Format("property {0} already exists", propertyName)); } mProperties[propertyName] = property; }
public virtual T GetPropertyValue <T>(string propertyName) { BOProperty property = GetProperty(propertyName); if (property == null) { throw new NotImplementedException(string.Format("[{0}] does not exists", propertyName)); } object value = property.Value; if (value is T) { return((T)value); } else if (typeof(T) == typeof(string)) { return((T)Convert.ChangeType(Convert.ToString(value), typeof(T))); } try { return((T)value); } catch (NullReferenceException nre) { throw new NullReferenceException(string.Format("Failed to cast property [{0}] to {1}", propertyName, typeof(T).ToString())); } catch (InvalidCastException ice) { throw new InvalidCastException(string.Format("Failed to cast property [{0}] to {1}", propertyName, typeof(T).ToString())); } }
public virtual void SetPropertyValue(string propertyName, object propertyValue) { BOProperty property = GetProperty(propertyName); if (property == null) { throw new NotImplementedException(string.Format("[{0}] does not exists", propertyName)); } property.Value = propertyValue; }
public virtual bool ValidateValue(string propertyName, object propertyValue, out string error) { BOProperty property = GetProperty(propertyName); if (property == null) { throw new NotImplementedException(string.Format("[{0}] does not exists", propertyName)); } return(property.ValidateValue(propertyValue, out error)); }
public virtual bool IsPropertyVisible(string propertyName) { BOProperty property = GetProperty(propertyName); if (mAccountant.CurrentAuthUser.CheckAccess(mObjectID, propertyName, BOPropertyAttrType.Visible)) { if (property == null) { throw new NotImplementedException(string.Format("[{0}] does not exists", propertyName)); } return(property.Visible); } return(false); }