22using System . Collections . Generic ;
33using System . Data ;
44using System . IO ;
5- using System . Linq ;
65using System . Reflection ;
76
87namespace NTestDataBuilder . DataSources . FileData
98{
10- public static class DataTableExtensions
9+ internal static class FileDataSourceHelpers
1110 {
12- public static IEnumerable < T > AsEnumerable < T > ( this DataTable table ) where T : new ( )
11+ internal static IEnumerable < T > AsEnumerable < T > ( this DataTable table ) where T : new ( )
1312 {
1413 if ( table == null )
1514 throw new NullReferenceException ( "DataTable" ) ;
@@ -36,39 +35,12 @@ public static class DataTableExtensions
3635 }
3736 objList . Add ( obj ) ;
3837 }
39-
4038 return objList ;
4139 }
42- }
43-
44- public class Person
45- {
46- public string FirstName { get ; set ; }
47- public string LastName { get ; set ; }
48- public string CompanyName { get ; set ; }
49- public string Address { get ; set ; }
50- public string City { get ; set ; }
51- public string County { get ; set ; }
52- public string Postal { get ; set ; }
53- public string Phone1 { get ; set ; }
54- public string Phone2 { get ; set ; }
55- public string Email { get ; set ; }
56- public string Web { get ; set ; }
57- }
58- public class PersonData
59- {
60- public static IList < Person > People { get ; private set ; }
61-
62- static PersonData ( )
63- {
64- People = ConvertCSVtoDataTable ( )
65- . AsEnumerable < Person > ( )
66- . ToList ( ) ;
67- }
6840
69- private static DataTable ConvertCSVtoDataTable ( )
41+ internal static DataTable ConvertCsvToDataTable ( string embeddedFilename )
7042 {
71- var stream = Assembly . GetExecutingAssembly ( ) . GetManifestResourceStream ( "NTestDataBuilder.DataSources.FileData.uk-500.csv" ) ;
43+ var stream = Assembly . GetExecutingAssembly ( ) . GetManifestResourceStream ( embeddedFilename ) ;
7244 var sr = new StreamReader ( stream ) ;
7345 var headers = sr . ReadLine ( ) . Split ( ',' ) ;
7446 var dt = new DataTable ( ) ;
@@ -89,4 +61,4 @@ private static DataTable ConvertCSVtoDataTable()
8961 return dt ;
9062 }
9163 }
92- }
64+ }
0 commit comments