Beispiel #1
0
 private object[] AutoDetectType(string[] data, ITableOptions tableOptions, out Type type)
 {
     type = TableFormatter.s_DefaultType;
     if (data == null || data.Length == 0 || tableOptions == null || !tableOptions.AutoDetectTypes)
     {
         return(data);
     }
     object[]        array  = new object[data.Length];
     ITypeDetector[] array2 = TableFormatter.s_TypeDetectors;
     for (int i = 0; i < array2.Length; i++)
     {
         ITypeDetector typeDetector = array2[i];
         bool          flag         = true;
         int           num          = tableOptions.UseColumnHeader ? 1 : 0;
         while (num < data.Length & flag)
         {
             if (string.IsNullOrEmpty(data[num]))
             {
                 array[num] = DBNull.Value;
             }
             else if (!typeDetector.CanConvert(data[num].ToString(), out array[num]))
             {
                 flag = false;
             }
             num++;
         }
         if (flag)
         {
             type = typeDetector.Type;
             return(array);
         }
     }
     return(data);
 }
Beispiel #2
0
 public PushingEngine(
     ISourceStreamReader sourceStreamReader,
     IEncodingProvider encodingProvider,
     ITypeDetector typeDetector,
     IXmlSerializer xmlSerializer)
 {
     _sourceStreamReader = sourceStreamReader;
     _encodingProvider   = encodingProvider;
     _typeDetector       = typeDetector;
     _xmlSerializer      = xmlSerializer;
 }