Parse() public abstract method

Parses the given value and returns the parsed object.
public abstract Parse ( string value ) : object
value string The value to parse.
return object
コード例 #1
0
 /// <summary>
 /// Parses the given values assuming that they are in the same order as the column definitions.
 /// </summary>
 /// <param name="values">The values to parse.</param>
 /// <returns>The parsed objects.</returns>
 internal object[] ParseValues(string[] values)
 {
     object[] parsed = new object[values.Length];
     for (int index = 0; index != values.Length; ++index)
     {
         ColumnDefinition definition = definitions[index];
         parsed[index] = definition.Parse(values[index]);
     }
     return(parsed);
 }
コード例 #2
0
        private static object parseValue(ColumnDefinition definition, object value)
        {
            // Let the definition interpret nulls.
            if (value == null)
            {
                return(definition.Parse(null));
            }
            // If the value is a string, give the parser a chance to interpret it.
            string asString = value as String;

            if (asString != null)
            {
                return(definition.Parse(asString));
            }
            // If the value's type differs from the expected type,
            // convert it to a string and try to interpret it.
            if (value.GetType() != definition.ColumnType)
            {
                return(Convert.ChangeType(value, definition.ColumnType));
            }
            // Otherwise, the type of the value matches the expected type.
            return(value);
        }
コード例 #3
0
 private static object parseValue(ColumnDefinition definition, object value)
 {
     // Let the definition interpret nulls.
     if (value == null)
     {
         return definition.Parse(null);
     }
     // If the value is a string, give the parser a chance to interpret it.
     string asString = value as String;
     if (asString != null)
     {
         return definition.Parse(asString);
     }
     // If the value's type differs from the expected type,
     // convert it to a string and try to interpret it.
     if (value.GetType() != definition.ColumnType)
     {
         return Convert.ChangeType(value, definition.ColumnType);
     }
     // Otherwise, the type of the value matches the expected type.
     return value;
 }