コード例 #1
0
        public object Retrieve(KeyValuePair <string, string> keyValuePair, Type targetType, Type propertyType)
        {
            if (string.IsNullOrWhiteSpace(keyValuePair.Value))
            {
                throw new NotSupportedException($"Table row column '{keyValuePair.Key}' does not support empty entry.");
            }
            if (MapDriver.IsNotSet(keyValuePair.Value))
            {
                return(0M);
            }

            var isPercentageRepresentation = keyValuePair.Value.Contains("%");
            var stringValue = keyValuePair.Value;

            if (isPercentageRepresentation)
            {
                stringValue = stringValue.Replace("%", "").Trim();
            }

            var value = decimal.Parse(stringValue);

            if (isPercentageRepresentation)
            {
                value *= 0.01M;
            }

            return(value);
        }
コード例 #2
0
 public decimal?NullableDecimalTransformation(string value)
 {
     if (MapDriver.IsNotSet(value))
     {
         return(null);
     }
     return(decimal.Parse(value));
 }
コード例 #3
0
        public DateTimeOffset TransformDateTimeOffset(string value)
        {
            if (MapDriver.IsNotSet(value))
            {
                throw new NotSupportedException("'Empty' entry to 'DateTimeOffset' transformation is not supported.");
            }

            return(DateConverter.GetDateOffset(value).Value);
        }
コード例 #4
0
        public static string ReplaceMagicStrings(this string value)
        {
            if (MapDriver.IsNotSet(value))
            {
                return(null);
            }

            var result = ReplaceMagicStringOfLength(value);

            result = DateConverter.ReplaceDate(result);

            return(result);
        }
コード例 #5
0
 private static DateTimeOffset GetValue(KeyValuePair <string, string> keyValuePair)
 {
     return(MapDriver.IsNotSet(keyValuePair.Value) ? default : DateConverter.GetDateOffset(keyValuePair.Value).Value);
 }
コード例 #6
0
 public object Retrieve(KeyValuePair <string, string> keyValuePair, Type targetType, Type propertyType)
 {
     return(MapDriver.IsNotSet(keyValuePair.Value)
                ? (int?)null
                : int.Parse(keyValuePair.Value.Replace(".", "").Replace(" ", "")));
 }
コード例 #7
0
 public object Retrieve(KeyValuePair <string, string> keyValuePair, Type targetType, Type propertyType)
 {
     return(MapDriver.IsNotSet(keyValuePair.Value)
         ? null
         : _retriever.Retrieve(keyValuePair, targetType, propertyType));
 }