Пример #1
0
 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);
 }
Пример #2
0
        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));
        }
Пример #3
0
        public static char?GetPropertyValAsNullableChar(TPropertyValue propertyValue)
        {
            var value = GetPropertyValAsString(propertyValue);

            if (!String.IsNullOrEmpty(value))
            {
                return(value[0]);
            }
            return(null);
        }
Пример #4
0
        public static string GetPropertyValAsString(TPropertyValue propertyValue)
        {
            var propertyVal = GetFromTPropertyValue <TPropertyString>(propertyValue);

            if (propertyVal != null)
            {
                return(propertyVal.Val);
            }
            return(null);
        }
Пример #5
0
        public static char GetPropertyValAsChar(TPropertyValue propertyValue)
        {
            var value = GetPropertyValAsString(propertyValue);

            if (!String.IsNullOrEmpty(value))
            {
                return(value[0]);
            }
            return(default(char));
        }
Пример #6
0
        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);
        }
Пример #7
0
        public static DateTime?GetPropertyValAsNullableDateTime(TPropertyValue propertyValue)
        {
            var value = GetPropertyValAsString(propertyValue);

            if (!String.IsNullOrEmpty(value))
            {
                try
                {
                    return(DateTime.Parse(value));
                }
                catch (Exception e) { }
            }
            return(null);
        }
Пример #8
0
 public static T?GetPropertyValAsNullableEnum <T>(TPropertyValue propertyValue) where T : struct
 {
     return(EnumHelper.ParseNullable <T>(GetPropertyValAsNullableInt(propertyValue)));
 }
Пример #9
0
 public static T GetPropertyValAsEnum <T>(TPropertyValue propertyValue) where T : struct
 {
     return(EnumHelper.Parse <T>(GetPropertyValAsInt(propertyValue)));
 }