コード例 #1
0
        public static CsvDataSheet Download(AbsoluteUri location)
        {
            if (null == location)
            {
                throw new ArgumentNullException("location");
            }

            CsvDataSheet csv = null;

            var request = WebRequest.Create((Uri)location);

            using (var response = request.GetResponse())
            {
                using (var stream = response.GetResponseStream())
                {
                    if (null != stream)
                    {
                        using (var reader = new StreamReader(stream))
                        {
#if NET20
                            var file = new FileInfo(StringExtensionMethods.FormatWith("{0}.csv", AlphaDecimal.Random()));
                            FileInfoExtensionMethods.Create(file, reader.ReadToEnd());
#else
                            var file = new FileInfo("{0}.csv".FormatWith(AlphaDecimal.Random()));
                            file.Create(reader.ReadToEnd());
#endif

                            csv = new CsvDataSheet(file);
                        }
                    }
                }
            }

            return(csv);
        }
コード例 #2
0
 public void op_IEnumerable_GetEnumerator()
 {
     using (var file = new TempFile())
     {
         file.Info.AppendLine("name");
         file.Info.AppendLine("Example");
         IEnumerable enumerable = new CsvDataSheet(file.Info);
         foreach (var entry in enumerable.Cast <KeyStringDictionary>())
         {
             Assert.Equal("Example", entry["name"]);
         }
     }
 }
コード例 #3
0
 public void usage_whenMultipleParameters(CsvDataSheet one,
                                          CsvDataSheet two)
 {
     Assert.Equal("one", one.First()["COLUMN"]);
     Assert.Equal("two", two.First()["COLUMN"]);
 }
コード例 #4
0
 public void usage(CsvDataSheet sheet)
 {
     Assert.Equal("A1", sheet.First()["A"]);
     Assert.Equal("B2", sheet.Last()["B"]);
 }
コード例 #5
0
 public void usage(CsvDataSheet csv)
 {
     Assert.Equal("A1", csv.First()["A"]);
     Assert.Equal("B2", csv.Last()["B"]);
 }