Exemple #1
0
        public DateTime?GetDateFieldFromPosition(FieldDefinitions.FieldDefinition position)
        {
            var      rawDate = GetStringFieldFromPosition(position);
            DateTime date;

            if (DateTime.TryParseExact(rawDate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
            {
                return(date);
            }
            return(null);
        }
Exemple #2
0
        public int?GetIntFieldFromPosition(FieldDefinitions.FieldDefinition position)
        {
            var parsedString = GetStringFieldFromPosition(position);

            if (string.IsNullOrWhiteSpace(parsedString))
            {
                return(null);
            }
            int result;

            if (!int.TryParse(parsedString, out result))
            {
                var ex = new InvalidOperationException($"Could not parse \"{parsedString}\" (position {position.StartPosition}) as int");
                // Save full parse string in the details
                ex.Data["PknodData"] = pknodData;
                throw ex;
            }
            return(result);
        }
Exemple #3
0
 public string GetStringFieldFromPosition(FieldDefinitions.FieldDefinition position)
 {
     return(pknodData.Substring(position.StartPosition - 1, position.Length).Trim());
 }