Esempio n. 1
0
        // void OutputValueAtCol_I(string c, int i, IUpdatableRow outputrow)
        //
        // Helper function that takes the string value c and puts it into the column at position i in the output row.
        // The value will be cast to the expected type of the column.
        private void OutputValueAtCol_I(string c, int i, IUpdatableRow outputrow)
        {
            ISchema schema = outputrow.Schema;

            if (schema[i].Type == typeof(SqlMap <string, string>))
            {
                c = DriverFunctions.RemoveOptionalQuotes(c);
                SqlMap <string, string> scopeMap = String.IsNullOrEmpty(c) ? null : DriverFunctions.ReadStringMap(c, this._map_item_delim, this._map_kv_delim);
                outputrow.Set <SqlMap <string, string> >(i, scopeMap);
            }
            else if (schema[i].Type == typeof(SqlArray <int>))
            {
                c = DriverFunctions.RemoveOptionalQuotes(c);
                SqlArray <int> scopeArray = String.IsNullOrEmpty(c) ? null : DriverFunctions.ReadIntArray(c, this._array_item_delim);
                outputrow.Set <SqlArray <int> >(i, scopeArray);
            }
            else if (schema[i].Type == typeof(int))
            {
                int num = Convert.ToInt32(c);
                outputrow.Set <int>(i, num);
            }
            else if (schema[i].Type == typeof(int?))
            {
                int?num2 = (c == "") ? null : new int?(Convert.ToInt32(c));
                outputrow.Set <int?>(i, num2);
            }
            else if (schema[i].Type == typeof(long))
            {
                long num3 = Convert.ToInt64(c);
                outputrow.Set <long>(i, num3);
            }
            else if (schema[i].Type == typeof(long?))
            {
                long?num4 = (c == "") ? null : new long?(Convert.ToInt64(c));
                outputrow.Set <long?>(i, num4);
            }
            else if (schema[i].Type == typeof(DateTime))
            {
                DateTime dateTime = Convert.ToDateTime(c);
                outputrow.Set <DateTime>(i, dateTime);
            }
            else if (schema[i].Type == typeof(DateTime?))
            {
                DateTime?dateTime2 = (c == "") ? null : new DateTime?(Convert.ToDateTime(c));
                outputrow.Set <DateTime?>(i, dateTime2);
            }
            else if (schema[i].Type == typeof(string))
            {
                string text = DriverFunctions.RemoveOptionalQuotes(c);
                outputrow.Set <string>(i, text);
            }
            else
            {
                outputrow.Set <string>(i, c);
            }
        }
Esempio n. 2
0
 // void WriteValue(object val, StreamWriter writer)
 //
 // Helper function that takes a value val and writes it into the output stream. It will convert the value to a string serialization.
 private void WriteValue(object val, StreamWriter writer)
 {
     if (val is SqlMap <string, string> )
     {
         writer.Write(DriverFunctions.WriteQuotedStringMap(val as SqlMap <string, string>, this._map_item_delim, this._map_kv_delim));
     }
     else if (val is SqlArray <int> )
     {
         writer.Write(DriverFunctions.WriteQuotedIntArray(val as SqlArray <int>, this._array_item_delim));
     }
     else if (val is string)
     {
         writer.Write(DriverFunctions.AddQuotes(val as string));
     }
     else
     {
         writer.Write(val);
     }
 }