/// <summary> /// Returns the localized property of any object as string using reflection. /// </summary> /// <param name="objObject">Object to access.</param> /// <param name="strPropertyName">Name of property.</param> /// <param name="strFormat">Format String.</param> /// <param name="formatProvider">specify formatting.</param> /// <param name="PropertyNotFound">out: specifies, whether property was found.</param> /// <returns>Localized Property.</returns> /// <remarks></remarks> public static string GetObjectProperty(object objObject, string strPropertyName, string strFormat, CultureInfo formatProvider, ref bool PropertyNotFound) { PropertyInfo objProperty = null; PropertyNotFound = false; if (CBO.GetProperties(objObject.GetType()).TryGetValue(strPropertyName, out objProperty)) { object propValue = objProperty.GetValue(objObject, null); Type t = typeof(string); if (propValue != null) { switch (objProperty.PropertyType.Name) { case "String": return(FormatString(Convert.ToString(propValue), strFormat)); case "Boolean": return(Boolean2LocalizedYesNo(Convert.ToBoolean(propValue), formatProvider)); case "DateTime": case "Double": case "Single": case "Int32": case "Int64": if (strFormat == string.Empty) { strFormat = "g"; } return(((IFormattable)propValue).ToString(strFormat, formatProvider)); } } else { return(string.Empty); } } PropertyNotFound = true; return(string.Empty); }