From 2a1cd4fda8a4a8e649910d16b4dfa1ce7ae63543 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 12 May 2023 09:24:40 +0800 Subject: *misc --- .../reading/enumerate-class-records/index.html | 457 ++++++++++++++++++ .../reading/get-anonymous-type-records/index.html | 451 ++++++++++++++++++ .../examples/reading/get-class-records/index.html | 452 ++++++++++++++++++ .../reading/get-dynamic-records/index.html | 446 ++++++++++++++++++ .../docs/examples/reading/index.html | 469 +++++++++++++++++++ .../examples/reading/reading-by-hand/index.html | 463 +++++++++++++++++++ .../reading/reading-multiple-data-sets/index.html | 514 +++++++++++++++++++++ .../reading-multiple-record-types/index.html | 497 ++++++++++++++++++++ 8 files changed, 3749 insertions(+) create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/enumerate-class-records/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/get-anonymous-type-records/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/get-class-records/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/get-dynamic-records/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/reading-by-hand/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/reading-multiple-data-sets/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/reading-multiple-record-types/index.html (limited to 'ThirdParty/CsvHelper-master/docs/examples/reading') diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/enumerate-class-records/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/enumerate-class-records/index.html new file mode 100644 index 0000000..4102d5d --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/enumerate-class-records/index.html @@ -0,0 +1,457 @@ + + + + + + + + + + + + + + + + + + + + + + + Enumerate Class Records | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Enumerate Class Records

+

Convert CSV rows into a class object that is re-used on every iteration of the enumerable. Each enumeration will hydrate the given record, but only the mapped members. If you supplied a map and didn't map one of the members, that member will not get hydrated with the current row's data. Be careful. Any methods that you call on the projection that force the evaluation of the IEnumerable, such as ToList(), you will get a list where all the records are the same instance you provided that is hydrated with the last record in the CSV file.

+
Data
+
Id,Name
+1,one
+
+
Example
+
void Main()
+{
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+    {
+		var record = new Foo();
+        var records = csv.EnumerateRecords(record);
+		foreach (var r in records)
+		{
+			// r is the same instance as record.
+		}
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/get-anonymous-type-records/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/get-anonymous-type-records/index.html new file mode 100644 index 0000000..44e5bac --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/get-anonymous-type-records/index.html @@ -0,0 +1,451 @@ + + + + + + + + + + + + + + + + + + + + + + + Get Anonymous Type Records | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Get Anonymous Type Records

+

Convert CSV rows into anonymous type objects. You just need to supply the anonymous type definition.

+
Data
+
Id,Name
+1,one
+
+
Example
+
void Main()
+{
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+    {
+		var anonymousTypeDefinition = new
+		{
+			Id = default(int),
+			Name = string.Empty
+		};
+        var records = csv.GetRecords(anonymousTypeDefinition);
+    }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/get-class-records/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/get-class-records/index.html new file mode 100644 index 0000000..98045ef --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/get-class-records/index.html @@ -0,0 +1,452 @@ + + + + + + + + + + + + + + + + + + + + + + + Get Class Records | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Get Class Records

+

Convert CSV rows into class objects.

+
Data
+
Id,Name
+1,one
+
+
Example
+
void Main()
+{
+	using (var reader = new StreamReader("path\\to\\file.csv"))
+	using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+	{
+		var records = csv.GetRecords<Foo>();
+	}
+}
+
+public class Foo
+{
+	public int Id { get; set; }
+	public string Name { get; set; }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/get-dynamic-records/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/get-dynamic-records/index.html new file mode 100644 index 0000000..d1b8eb8 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/get-dynamic-records/index.html @@ -0,0 +1,446 @@ + + + + + + + + + + + + + + + + + + + + + + + Get Dynamic Records | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Get Dynamic Records

+

Convert CSV rows into dynamic objects. Since there is no way to tell what type the properties should be, all the properties on the dynamic object are strings.

+
Data
+
Id,Name
+1,one
+
+
Example
+
void Main()
+{
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+    {
+        var records = csv.GetRecords<dynamic>();
+    }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/index.html new file mode 100644 index 0000000..cb0538a --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/index.html @@ -0,0 +1,469 @@ + + + + + + + + + + + + + + + + + + + + + + + Reading | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+ +
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/reading-by-hand/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/reading-by-hand/index.html new file mode 100644 index 0000000..dc8cb29 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/reading-by-hand/index.html @@ -0,0 +1,463 @@ + + + + + + + + + + + + + + + + + + + + + + + Reading By Hand | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Reading by Hand

+

Sometimes it's easier to not try and configure a mapping to match your class definition for various reasons. It's usually only a few more lines of code to just read the rows by hand instead.

+
Data
+
Id,Name
+1,one
+
+
Example
+
void Main()
+{
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+    {
+        var records = new List<Foo>();
+		csv.Read();
+		csv.ReadHeader();
+		while (csv.Read())
+		{
+			var record = new Foo
+			{
+				Id = csv.GetField<int>("Id"),
+				Name = csv.GetField("Name")
+			};
+			records.Add(record);
+		}
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/reading-multiple-data-sets/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/reading-multiple-data-sets/index.html new file mode 100644 index 0000000..baba878 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/reading-multiple-data-sets/index.html @@ -0,0 +1,514 @@ + + + + + + + + + + + + + + + + + + + + + + + Reading Multiple Data Sets | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Reading Multiple Data Sets

+

For some reason there are CSV files out there that contain multiple sets of CSV data in them. You should be able to read files like this without issue. You will need to detect when to change class types you are retreiving.

+
Data
+
FooId,Name
+1,foo
+
+BarId,Name
+07a0fca2-1b1c-4e44-b1be-c2b05da5afc7,bar
+
+
Example
+
void Main()
+{
+    var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+	{
+		IgnoreBlankLines = false,		
+	};
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, config))
+    {
+		csv.Context.RegisterClassMap<FooMap>();
+		csv.Context.RegisterClassMap<BarMap>();
+		var fooRecords = new List<Foo>();
+		var barRecords = new List<Bar>();
+		var isHeader = true;
+		while (csv.Read())
+		{
+			if (isHeader)
+			{
+				csv.ReadHeader();
+				isHeader = false;
+				continue;
+			}
+			
+			if (string.IsNullOrEmpty(csv.GetField(0)))
+			{
+				isHeader = true;
+				continue;
+			}
+
+			switch (csv.HeaderRecord[0])
+			{
+				case "FooId":
+					fooRecords.Add(csv.GetRecord<Foo>());
+					break;
+				case "BarId":
+					barRecords.Add(csv.GetRecord<Bar>());
+					break;
+				default:
+					throw new InvalidOperationException("Unknown record type.");
+			}
+		}
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+}
+
+public class Bar
+{
+	public Guid Id { get; set; }
+	public string Name { get; set; }
+}
+
+public sealed class FooMap : ClassMap<Foo>
+{
+	public FooMap()
+	{
+		Map(m => m.Id).Name("FooId");
+		Map(m => m.Name);
+	}
+}
+
+public sealed class BarMap : ClassMap<Bar>
+{
+	public BarMap()
+	{
+		Map(m => m.Id).Name("BarId");
+		Map(m => m.Name);
+	}
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/reading-multiple-record-types/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/reading-multiple-record-types/index.html new file mode 100644 index 0000000..c86999e --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/reading-multiple-record-types/index.html @@ -0,0 +1,497 @@ + + + + + + + + + + + + + + + + + + + + + + + Reading Multiple Record Types | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Reading Multiple Record Types

+

If you have CSV data where each row may be a different record type, you should be able to read based on a row type or something similar.

+
Data
+
A,1,foo
+B,07a0fca2-1b1c-4e44-b1be-c2b05da5afc7,bar
+
+
Example
+
void Main()
+{
+	var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+	{
+		HasHeaderRecord = false,
+	};
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, config))
+    {
+		csv.Context.RegisterClassMap<FooMap>();
+		csv.Context.RegisterClassMap<BarMap>();
+		var fooRecords = new List<Foo>();
+		var barRecords = new List<Bar>();
+		while (csv.Read())
+		{
+			switch (csv.GetField(0))
+			{
+				case "A":
+					fooRecords.Add(csv.GetRecord<Foo>());
+					break;
+				case "B":
+					barRecords.Add(csv.GetRecord<Bar>());
+					break;
+				default:
+					throw new InvalidOperationException("Unknown record type.");
+			}
+		}
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+}
+
+public class Bar
+{
+	public Guid Id { get; set; }
+	public string Name { get; set; }
+}
+
+public sealed class FooMap : ClassMap<Foo>
+{
+	public FooMap()
+	{
+		Map(m => m.Id).Index(1);
+		Map(m => m.Name).Index(2);
+	}
+}
+
+public sealed class BarMap : ClassMap<Bar>
+{
+	public BarMap()
+	{
+		Map(m => m.Id).Index(1);
+		Map(m => m.Name).Index(2);
+	}
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + -- cgit v1.1-26-g67d0