/// <summary> /// Parses the given value as a char array. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>The parsed char array.</returns> public override object Parse(string value) { if (NullHandler.IsNullRepresentation(value)) { return(null); } value = TrimValue(value); return(value.ToCharArray()); }
/// <summary> /// Parses the given value into a byte. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>The parsed byte value.</returns> public override object Parse(string value) { if (NullHandler.IsNullRepresentation(value)) { return(null); } IFormatProvider provider = FormatProvider ?? CultureInfo.CurrentCulture; return(Byte.Parse(value, NumberStyles, provider)); }
/// <summary> /// Parses the given value as a byte array. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>The parsed byte array.</returns> public override object Parse(string value) { if (NullHandler.IsNullRepresentation(value)) { return(null); } value = TrimValue(value); Encoding encoding = Encoding ?? Encoding.Default; return(encoding.GetBytes(value)); }
/// <summary> /// Returns the given value trimmed. /// </summary> /// <param name="value">The value to trim.</param> /// <returns>The value trimmed.</returns> public override object Parse(string value) { if (Trim && value != null) { value = TrimValue(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } return(value); }
/// <summary> /// Parses the given value into its equivalent enum value. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>The enum value that was parsed.</returns> public override object Parse(string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } return(parser(value)); }
/// <summary> /// Parses the given value as a char array. /// </summary> /// <param name="context">Holds information about the column current being processed.</param> /// <param name="value">The value to parse.</param> /// <returns>The parsed char array.</returns> public override object Parse(IColumnContext context, string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } value = TrimValue(value); return(value.ToCharArray()); }
/// <summary> /// Parses the given value into a byte. /// </summary> /// <param name="context">Holds information about the column current being processed.</param> /// <param name="value">The value to parse.</param> /// <returns>The parsed byte value.</returns> public override object Parse(IColumnContext context, string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } IFormatProvider provider = FormatProvider ?? CultureInfo.CurrentCulture; return(Byte.Parse(value, NumberStyles, provider)); }
/// <summary> /// Parses the given value as a byte array. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>The parsed byte array.</returns> public override object Parse(string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } value = TrimValue(value); Encoding actualEncoding = Encoding ?? new UTF8Encoding(false); return(actualEncoding.GetBytes(value)); }
/// <summary> /// Parses the given value and returns a Guid instance. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>The parsed Guid.</returns> public override object Parse(string value) { if (NullHandler.IsNullRepresentation(value)) { return(null); } if (InputFormat == null) { return(Guid.Parse(value)); } else { return(Guid.ParseExact(value, InputFormat)); } }
/// <summary> /// Parses the given value, returning a Double. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>The parsed Double.</returns> public override object Parse(string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } IFormatProvider provider = FormatProvider ?? CultureInfo.CurrentCulture; value = TrimValue(value); return(Double.Parse(value, NumberStyles, provider)); }
/// <summary> /// Parses the given value as a char. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>The parsed char.</returns> public override object Parse(string value) { if (NullHandler.IsNullRepresentation(value)) { return(null); } value = TrimValue(value); if (AllowTrailing || value.Length == 1) { return(value[0]); } else { throw new InvalidCastException(); } }
/// <summary> /// Parses the given value and returns a Guid instance. /// </summary> /// <param name="context">Holds information about the column current being processed.</param> /// <param name="value">The value to parse.</param> /// <returns>The parsed Guid.</returns> public override object Parse(IColumnContext context, string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } if (InputFormat == null) { return(Guid.Parse(value)); } return(Guid.ParseExact(value, InputFormat)); }
/// <summary> /// Parses the given value into its equivilent boolean value. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>True if the value equals the TrueString; otherwise, false.</returns> public override object Parse(string value) { if (NullHandler.IsNullRepresentation(value)) { return(null); } value = TrimValue(value); if (String.Equals(value, TrueString, StringComparison.CurrentCultureIgnoreCase)) { return(true); } if (String.Equals(value, FalseString, StringComparison.CurrentCultureIgnoreCase)) { return(false); } throw new InvalidCastException(); }
/// <summary> /// Parses the given value and returns a DateTime instance. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>The parsed DateTime instance.</returns> public override object Parse(string value) { if (NullHandler.IsNullRepresentation(value)) { return(null); } IFormatProvider provider = FormatProvider ?? CultureInfo.CurrentCulture; if (InputFormat == null) { return(DateTime.Parse(value, provider)); } else { return(DateTime.ParseExact(value, InputFormat, provider)); } }
/// <summary> /// Parses the given value as a char. /// </summary> /// <param name="context">Holds information about the column current being processed.</param> /// <param name="value">The value to parse.</param> /// <returns>The parsed char.</returns> public override object Parse(IColumnContext context, string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } value = TrimValue(value); if (AllowTrailing || value.Length == 1) { return(value[0]); } throw new InvalidCastException(); }
/// <summary> /// Parses the given value and returns a DateTime instance. /// </summary> /// <param name="context">Holds information about the column current being processed.</param> /// <param name="value">The value to parse.</param> /// <returns>The parsed DateTime instance.</returns> public override object Parse(IColumnContext context, string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } IFormatProvider provider = FormatProvider ?? CultureInfo.CurrentCulture; if (InputFormat == null) { return(DateTime.Parse(value, provider)); } return(DateTime.ParseExact(value, InputFormat, provider)); }
/// <summary> /// Extracts a single record from the embedded data. /// </summary> /// <param name="value">The value containing the embedded data.</param> /// <returns> /// An object array containing the values read from the embedded data -or- null if there is no embedded data. /// </returns> public override object Parse(string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } StringReader stringReader = new StringReader(value); SeparatedValueReader reader = getReader(stringReader); if (reader.Read()) { return(reader.GetValues()); } return(null); }
/// <summary> /// Extracts a single record from the embedded data. /// </summary> /// <param name="value">The value containing the embedded data.</param> /// <returns> /// An object array containing the values read from the embedded data -or- null if there is no embedded data. /// </returns> public override object Parse(string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } var stringReader = new StringReader(value); var reader = new FixedLengthReader(stringReader, schema, Options); if (reader.Read()) { return(reader.GetValues()); } return(null); }
/// <summary> /// Extracts a single record from the embedded data. /// </summary> /// <param name="context">Holds information about the column current being processed.</param> /// <param name="value">The value containing the embedded data.</param> /// <returns> /// An object array containing the values read from the embedded data -or- null if there is no embedded data. /// </returns> public override object Parse(IColumnContext context, string value) { if (Preprocessor != null) { value = Preprocessor(value); } if (NullHandler.IsNullRepresentation(value)) { return(null); } var stringReader = new StringReader(value); var reader = GetReader(stringReader); if (reader.Read()) { return(reader.GetValues()); } return(null); }