public static T GetFromTPropertyValue <T>(TPropertyValue propertyValue) where T : TPropertyVal { if (propertyValue != null && propertyValue.PropertyVal != null && propertyValue.PropertyVal.GetType() == typeof(T)) { return((T)propertyValue.PropertyVal); } return(null); }
public static bool GetPropertyValAsBool(TPropertyValue propertyValue) { var propertyVal = GetFromTPropertyValue <TPropertyString>(propertyValue); if (propertyVal != null && !String.IsNullOrEmpty(propertyVal.Val)) { return(propertyVal.Val == "1"); } return(default(bool)); }
public static char?GetPropertyValAsNullableChar(TPropertyValue propertyValue) { var value = GetPropertyValAsString(propertyValue); if (!String.IsNullOrEmpty(value)) { return(value[0]); } return(null); }
public static string GetPropertyValAsString(TPropertyValue propertyValue) { var propertyVal = GetFromTPropertyValue <TPropertyString>(propertyValue); if (propertyVal != null) { return(propertyVal.Val); } return(null); }
public static char GetPropertyValAsChar(TPropertyValue propertyValue) { var value = GetPropertyValAsString(propertyValue); if (!String.IsNullOrEmpty(value)) { return(value[0]); } return(default(char)); }
public static int?GetPropertyValAsNullableInt(TPropertyValue propertyValue) { var propertyVal = GetFromTPropertyValue <TPropertyString>(propertyValue); if (propertyVal != null && !String.IsNullOrEmpty(propertyVal.Val)) { try { return(int.Parse(propertyVal.Val)); } catch (Exception e) { } } return(null); }
public static DateTime?GetPropertyValAsNullableDateTime(TPropertyValue propertyValue) { var value = GetPropertyValAsString(propertyValue); if (!String.IsNullOrEmpty(value)) { try { return(DateTime.Parse(value)); } catch (Exception e) { } } return(null); }
public static T?GetPropertyValAsNullableEnum <T>(TPropertyValue propertyValue) where T : struct { return(EnumHelper.ParseNullable <T>(GetPropertyValAsNullableInt(propertyValue))); }
public static T GetPropertyValAsEnum <T>(TPropertyValue propertyValue) where T : struct { return(EnumHelper.Parse <T>(GetPropertyValAsInt(propertyValue))); }