Ejemplo n.º 1
0
        /// <summary>
        /// Gets the stub header.
        /// </summary>
        /// <param name="feature">The feature.</param>
        /// <param name="count">The count.</param>
        /// <returns></returns>
        public static DbaseFileHeader GetHeader(Feature feature, int count)
        {
            IAttributesTable attribs = feature.Attributes;

            string[]        names  = attribs.GetNames();
            DbaseFileHeader header = new DbaseFileHeader();

            header.NumRecords = count;
            foreach (string name in names)
            {
                Type type = attribs.GetType(name);
                if (type == typeof(double) || type == typeof(float))
                {
                    header.AddColumn(name, 'N', DoubleLength, DoubleDecimals);
                }
                else if (type == typeof(short) || type == typeof(ushort) ||
                         type == typeof(int) || type == typeof(uint) ||
                         type == typeof(long) || type == typeof(ulong))
                {
                    header.AddColumn(name, 'N', IntLength, IntDecimals);
                }
                else if (type == typeof(string))
                {
                    header.AddColumn(name, 'C', StringLength, StringDecimals);
                }
                else if (type == typeof(bool))
                {
                    throw new NotImplementedException("Boolean values currently not supported");
                }
                else if (type == typeof(DateTime))
                {
                    throw new NotImplementedException("DateTime values currently not supported");
                }
                else
                {
                    throw new ArgumentException("Type " + type.Name + " not supported");
                }
            }
            return(header);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="recordCount"></param>
        public static void WriteDummyDbf(string filename, int recordCount)
        {
            DbaseFileHeader dbfHeader = new DbaseFileHeader();
            dbfHeader.AddColumn("Description",'C', 20, 0);

            DbaseFileWriter dbfWriter = new DbaseFileWriter(filename);
            dbfWriter.Write(dbfHeader);
            for (int i = 0; i < recordCount; i++)
            {
                ArrayList columnValues = new ArrayList();
                columnValues.Add((double) i);
                dbfWriter.Write(columnValues);
            }
            dbfWriter.Close();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="recordCount"></param>
        public static void WriteDummyDbf(string filename, int recordCount)
        {
            DbaseFileHeader dbfHeader = new DbaseFileHeader();

            dbfHeader.AddColumn("Description", 'C', 20, 0);

            DbaseFileWriter dbfWriter = new DbaseFileWriter(filename);

            dbfWriter.Write(dbfHeader);
            for (int i = 0; i < recordCount; i++)
            {
                ArrayList columnValues = new ArrayList();
                columnValues.Add((double)i);
                dbfWriter.Write(columnValues);
            }
            dbfWriter.Close();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the stub header.
 /// </summary>
 /// <param name="feature">The feature.</param>
 /// <param name="count">The count.</param>
 /// <returns></returns>
 public static DbaseFileHeader GetHeader(Feature feature, int count)
 {
     IAttributesTable attribs = feature.Attributes;
     string[] names = attribs.GetNames();
     DbaseFileHeader header = new DbaseFileHeader();
     header.NumRecords = count;
     foreach (string name in names)
     {
         Type type = attribs.GetType(name);
         if (type == typeof(double) || type == typeof(float))
             header.AddColumn(name, 'N', DoubleLength, DoubleDecimals);
         else if (type == typeof(short) || type == typeof(ushort) ||
                  type == typeof(int) || type == typeof(uint) ||
                  type == typeof(long) || type == typeof(ulong))
             header.AddColumn(name, 'N', IntLength, IntDecimals);
         else if (type == typeof(string))
             header.AddColumn(name, 'C', StringLength, StringDecimals);
         else if (type == typeof(bool))
             throw new NotImplementedException("Boolean values currently not supported");
         else if (type == typeof(DateTime))
             throw new NotImplementedException("DateTime values currently not supported");
         else throw new ArgumentException("Type " + type.Name + " not supported");
     }
     return header;
 }