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 --- .../class-maps/auto-mapping/index.html | 462 ++++++++++++++++++ .../class-maps/constant-value/index.html | 464 +++++++++++++++++++ .../class-maps/ignoring-properties/index.html | 463 ++++++++++++++++++ .../examples/configuration/class-maps/index.html | 489 +++++++++++++++++++ .../class-maps/inline-type-conversion/index.html | 515 +++++++++++++++++++++ .../mapping-by-alternate-names/index.html | 462 ++++++++++++++++++ .../class-maps/mapping-by-index/index.html | 465 +++++++++++++++++++ .../class-maps/mapping-by-name/index.html | 462 ++++++++++++++++++ .../class-maps/mapping-duplicate-names/index.html | 464 +++++++++++++++++++ .../class-maps/mapping-properties/index.html | 462 ++++++++++++++++++ .../class-maps/optional-maps/index.html | 464 +++++++++++++++++++ .../class-maps/type-conversion/index.html | 482 +++++++++++++++++++ .../configuration/class-maps/validation/index.html | 463 ++++++++++++++++++ 13 files changed, 6117 insertions(+) create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/auto-mapping/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/constant-value/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/ignoring-properties/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/inline-type-conversion/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-alternate-names/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-index/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-name/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-duplicate-names/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-properties/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/optional-maps/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/type-conversion/index.html create mode 100644 ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/validation/index.html (limited to 'ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps') diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/auto-mapping/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/auto-mapping/index.html new file mode 100644 index 0000000..e410ab5 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/auto-mapping/index.html @@ -0,0 +1,462 @@ + + + + + + + + + + + + + + + + + + + + + + + Auto Mapping | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Auto Mapping

+

If you don't supply a map to the configuration, one is automatically created for you on the fly. You can call auto mapping directly in your class map also. You may want to do this if you have a large number of properties that will be set up correctly by default, and only need to make a couple changes.

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

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/constant-value/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/constant-value/index.html new file mode 100644 index 0000000..8c4b933 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/constant-value/index.html @@ -0,0 +1,464 @@ + + + + + + + + + + + + + + + + + + + + + + + Constant Value | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Constant Value

+

You can set a constant value to a property instead of mapping it to a field.

+
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))
+    {
+        csv.Context.RegisterClassMap<FooMap>();
+        var records = csv.GetRecords<Foo>();
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+    public bool IsDirty { get; set; }
+}
+
+public sealed class FooMap : ClassMap<Foo>
+{
+    public FooMap()
+    {
+		Map(m => m.Id);
+		Map(m => m.Name);
+        Map(m => m.IsDirty).Constant(true);
+    }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/ignoring-properties/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/ignoring-properties/index.html new file mode 100644 index 0000000..8a8b126 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/ignoring-properties/index.html @@ -0,0 +1,463 @@ + + + + + + + + + + + + + + + + + + + + + + + Ignoring Properties | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Ignoring Properties

+

When you use auto mapping in your class map, every property will get mapped. If there are properties that you don't want mapped, you can ignore them.

+
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))
+    {
+        csv.Context.RegisterClassMap<FooMap>();
+        var records = csv.GetRecords<Foo>();
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+    public bool IsDirty { get; set; }
+}
+
+public sealed class FooMap : ClassMap<Foo>
+{
+    public FooMap()
+    {
+        AutoMap(CultureInfo.InvariantCulture);
+        Map(m => m.IsDirty).Ignore();
+    }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/index.html new file mode 100644 index 0000000..26c946e --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/index.html @@ -0,0 +1,489 @@ + + + + + + + + + + + + + + + + + + + + + + + Class Maps | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Class Maps

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Topics 
Mapping PropertiesMapping to properties.
Mapping by NameMapping properties by header name.
Mapping by Alternate NamesMapping properties that may be one of many names.
Mapping Duplicate NamesMapping properties that have duplicate header names.
Mapping by IndexMapping properties by header index position.
Auto MappingAutomatic mapping.
Ignoring PropertiesIgnoring mapped properites.
Constant ValueSetting a constant value for a property.
Type ConversionUsing a specific type converter.
Inline Type ConversionConvert a field to a type inline.
Optional MapsMap a property only if it exists.
ValidationValidate a field value.
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/inline-type-conversion/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/inline-type-conversion/index.html new file mode 100644 index 0000000..0ec199e --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/inline-type-conversion/index.html @@ -0,0 +1,515 @@ + + + + + + + + + + + + + + + + + + + + + + + Inline Type Conversion | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Inline Type Conversion

+

If you don't want to write a full ITypeConverter implementation, you can specify a function that will do the same thing.

+

Reading

+
Data
+
Id,Name,Json
+1,one,"{ ""Foo"": ""Bar"" }"
+
+
Example
+
void Main()
+{
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+    {
+        csv.Context.RegisterClassMap<FooMap>();
+        csv.GetRecords<Foo>().ToList().Dump();
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+    public Json Json { get; set; }
+}
+
+public class Json
+{
+    public string Foo { get; set; }
+}
+
+public class FooMap : ClassMap<Foo>
+{
+    public FooMap()
+    {
+        Map(m => m.Id);
+        Map(m => m.Name);
+        Map(m => m.Json).Convert(row => JsonConvert.DeserializeObject<Json>(row.GetField("Json")));
+    }
+}
+
+

Writing

+
Example
+
void Main()
+{
+	var records = new List<Foo>
+	{
+		new Foo { Id = 1, Name = "one" }
+	};
+	
+	using (var writer = new StreamWriter("path\\to\\file.csv"))
+	using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+	{
+		csv.Context.RegisterClassMap<FooMap>();
+		csv.WriteRecords(records);
+		
+		writer.ToString().Dump();
+	}
+}
+
+public class Foo
+{
+	public int Id { get; set; }
+	public string Name { get; set; }
+	public Json Json { get; set; }
+}
+
+public class Json
+{
+	public string Foo { get; set; }
+}
+
+public class FooMap : ClassMap<Foo>
+{
+	public FooMap()
+	{
+		Map(m => m.Id);
+		Map(m => m.Name);
+		Map(m => m.Json).Convert(o => JsonConvert.SerializeObject(o));
+	}
+}
+
+
Output
+
Id,Name,Json
+1,one,"{""Id"":1,""Name"":""one"",""Json"":null}"
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-alternate-names/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-alternate-names/index.html new file mode 100644 index 0000000..62e3bd7 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-alternate-names/index.html @@ -0,0 +1,462 @@ + + + + + + + + + + + + + + + + + + + + + + + Mapping By Alternate Names | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Mapping by Alternate Names

+

If you have a header name that could vary, you can specify multiple header names.

+
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))
+    {
+        csv.Context.RegisterClassMap<FooMap>();
+        var records = csv.GetRecords<Foo>();
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get set; }
+}
+
+public sealed class FooMap : ClassMap<Foo>
+{
+    public FooMap()
+    {
+        Map(m => m.Id).Name("TheId", "Id");
+        Map(m => m.Name).Name("TheName", "Name");
+    }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-index/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-index/index.html new file mode 100644 index 0000000..9aa7759 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-index/index.html @@ -0,0 +1,465 @@ + + + + + + + + + + + + + + + + + + + + + + + Mapping By Index | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Mapping by Index

+

If your data doesn't have a header you can map by index instead of name. You can't rely on the order of class properties in .NET, so if you're not mapping by name, make sure you specify an index.

+
Data
+
1,one
+
+
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>();
+        var records = csv.GetRecords<Foo>();
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get set; }
+}
+
+public sealed class FooMap : ClassMap<Foo>
+{
+    public FooMap()
+    {
+        Map(m => m.Id).Index(0);
+        Map(m => m.Name).Index(1);
+    }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-name/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-name/index.html new file mode 100644 index 0000000..cb15885 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-by-name/index.html @@ -0,0 +1,462 @@ + + + + + + + + + + + + + + + + + + + + + + + Mapping By Name | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Mapping by Name

+

If your property names don't match your class names, you can map the property to the column by name.

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

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-duplicate-names/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-duplicate-names/index.html new file mode 100644 index 0000000..d7dc521 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-duplicate-names/index.html @@ -0,0 +1,464 @@ + + + + + + + + + + + + + + + + + + + + + + + Mapping Duplicate Names | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Mapping Duplicate Names

+

Sometimes you have duplicate header names. This is handled through a header name index. The name index is the index of how many occurrences of that header name there are, not the position of the header.

+
Data
+
Id,Name,Name
+1,first,last
+
+
Example
+
void Main()
+{
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+    {
+        csv.Context.RegisterClassMap<FooMap>();
+        var records = csv.GetRecords<Foo>();
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string FirstName { get set; }
+	public string LastName { get; set; }
+}
+
+public sealed class FooMap : ClassMap<Foo>
+{
+    public FooMap()
+    {
+        Map(m => m.Id);
+        Map(m => m.FirstName).Name("Name").NameIndex(0);
+		Map(m => m.LastName).Name("Name").NameIndex(1);
+    }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-properties/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-properties/index.html new file mode 100644 index 0000000..05640ec --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/mapping-properties/index.html @@ -0,0 +1,462 @@ + + + + + + + + + + + + + + + + + + + + + + + Mapping Properties | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Mapping Properties

+

This will map the properties of a class to the header names of the CSV data. The mapping needs to be registered in the context. This example is identical to not using a class mapping at all. The headers match the property names.

+
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))
+	{		
+		csv.Context.RegisterClassMap<FooMap>();
+		var records = csv.GetRecords<Foo>();
+	}
+}
+
+public class Foo
+{
+	public int Id { get; set; }	
+	public string Name { get; set; }
+}
+
+public sealed class FooMap : ClassMap<Foo>
+{
+	public FooMap()
+	{
+		Map(m => m.Id);
+		Map(m => m.Name);
+	}
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/optional-maps/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/optional-maps/index.html new file mode 100644 index 0000000..d57dcad --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/optional-maps/index.html @@ -0,0 +1,464 @@ + + + + + + + + + + + + + + + + + + + + + + + Optional Maps | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Optional Maps

+

If you have data that may or may not have a header, you can make the mapping optional.

+
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))
+	{
+		csv.Context.RegisterClassMap<FooMap>();
+		csv.GetRecords<Foo>().ToList().Dump();
+	}
+}
+
+public class Foo
+{
+	public int Id { get; set; }
+	public string Name { get; set; }
+	public DateTimeOffset? Date { get; set; }
+}
+
+public class FooMap : ClassMap<Foo>
+{
+	public FooMap()
+	{
+		Map(m => m.Id);
+		Map(m => m.Name);
+		Map(m => m.Date).Optional();
+	}
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/type-conversion/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/type-conversion/index.html new file mode 100644 index 0000000..56bf740 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/type-conversion/index.html @@ -0,0 +1,482 @@ + + + + + + + + + + + + + + + + + + + + + + + Type Conversion | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Type Conversion

+

If you need to convert to or from a non-standard .NET type, you can supply a type converter to use for a property.

+
Data
+
Id,Name,Json
+1,one,"{ ""Foo"": ""Bar"" }"
+
+
Example
+
void Main()
+{
+	using (var reader = new StreamReader("path\\to\\file.csv"))
+	using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+	{
+		csv.Context.RegisterClassMap<FooMap>();
+		csv.GetRecords<Foo>().ToList().Dump();
+	}
+}
+
+public class Foo
+{
+	public int Id { get; set; }
+	public string Name { get; set; }
+	public Json Json { get; set; }
+}
+
+public class Json
+{
+	public string Foo { get; set; }
+}
+
+public class JsonConverter<T> : DefaultTypeConverter
+{
+	public override object ConvertFromString(string text, IReaderRow row, MemberMapData memberMapData)
+	{
+		return JsonConvert.DeserializeObject<T>(text);
+	}
+
+	public override string ConvertToString(object value, IWriterRow row, MemberMapData memberMapData)
+	{
+		return JsonConvert.SerializeObject(value);
+	}
+}
+
+public class FooMap : ClassMap<Foo>
+{
+	public FooMap()
+	{
+		Map(m => m.Id);
+		Map(m => m.Name);
+		Map(m => m.Json).TypeConverter<JsonConverter<Json>>();
+	}
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + diff --git a/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/validation/index.html b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/validation/index.html new file mode 100644 index 0000000..b97f314 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/configuration/class-maps/validation/index.html @@ -0,0 +1,463 @@ + + + + + + + + + + + + + + + + + + + + + + + Validation | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Validation

+

If you want to ensure your data conforms to some sort of standard, you can validate it.

+
Data
+
Id,Name
+1,on-e
+
+
Example
+
void Main()
+{
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+    {
+        csv.Context.RegisterClassMap<FooMap>();
+        csv.GetRecords<Foo>().ToList().Dump();
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+    public DateTimeOffset? Date { get; set; }
+}
+
+public class FooMap : ClassMap<Foo>
+{
+    public FooMap()
+    {
+        Map(m => m.Id);
+        Map(m => m.Name).Validate(field => !field.Contains("-"));
+    }
+}
+
+ +
+
+
+
+ +

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