コード例 #1
0
        public void checkProxy()
        {
            var    fieldLength = 2400;
            string writtenValue;

            using (
                Stream fos =
                    File.Open(TestSelectPath(),
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                using (var writer = new DBFWriter {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath(), "DBT")
                })
                {
                    ;
                    var field  = new DBFField("F1", NativeDbType.Memo);
                    var field2 = new DBFField("F2", NativeDbType.Numeric, 10);
                    var field3 = new DBFField("F3", NativeDbType.Char, 10);
                    writer.Fields = new[] { field, field2, field3 };

                    writtenValue = "alpha";
                    writer.AddRecord(new MemoValue(GetCharacters(fieldLength)), 10, writtenValue);
                    writer.Write(fos);
                }
            }
            using (
                Stream fis =
                    File.Open(TestSelectPath(),
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                using (var reader = new DBFReader(fis)
                {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath(), "DBT")
                })
                {
                    var readValues = reader.AllRecords <ITestInterface>();

                    Assert.That(readValues.First().F3, StartsWith(writtenValue), "Written Value not equaling Read");
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Return all the records. T should be interface with getter properties that match types and names of the database.
 /// Optionally instead of T being and interface you can pass in an anonymous object with properties that match that
 /// database and then you'll get an IEnumerable of that anonymous type with the data filled in.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="reader">The reader.</param>
 /// <param name="prototype">The prototype. Anonymous class instance</param>
 /// <returns></returns>
 public static IEnumerable <T> AllRecords <T>(DBFReader reader, T prototype = null) where T : class
 {
     return(reader.AllRecords(prototype));
 }