diff options
Diffstat (limited to 'ThirdParty/CsvHelper-master/src/CsvHelper/Delegates')
15 files changed, 668 insertions, 0 deletions
diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/BadDataFound.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/BadDataFound.cs new file mode 100644 index 0000000..5f25912 --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/BadDataFound.cs @@ -0,0 +1,52 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that gets called when bad data is found. + /// </summary> + /// <param name="args">The args.</param> + public delegate void BadDataFound(BadDataFoundArgs args); + + /// <summary> + /// Information about the field that caused <see cref="BadDataFound"/> to be called. + /// </summary> + public readonly struct BadDataFoundArgs + { + /// <summary> + /// The full field unedited. + /// </summary> + public readonly string Field; + + /// <summary> + /// The full row unedited. + /// </summary> + public readonly string RawRecord; + + /// <summary> + /// The context. + /// </summary> + public readonly CsvContext Context; + + /// <summary> + /// Creates a new instance of BadDataFoundArgs. + /// </summary> + /// <param name="field">The full field unedited.</param> + /// <param name="rawRecord">The full row unedited.</param> + /// <param name="context">The context.</param> + public BadDataFoundArgs(string field, string rawRecord, CsvContext context) + { + Field = field; + RawRecord = rawRecord; + Context = context; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ConvertFromString.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ConvertFromString.cs new file mode 100644 index 0000000..48b2512 --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ConvertFromString.cs @@ -0,0 +1,40 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that converts a string into an object. + /// </summary> + /// <typeparam name="TMember">The type of the member.</typeparam> + /// <param name="args">The args.</param> + /// <returns>The class object.</returns> + public delegate TMember ConvertFromString<TMember>(ConvertFromStringArgs args); + + /// <summary> + /// <see cref="ConvertFromString{TMember}"/> args. + /// </summary> + public readonly struct ConvertFromStringArgs + { + /// <summary> + /// The row. + /// </summary> + public readonly IReaderRow Row; + + /// <summary> + /// Creates a new instance of ConvertFromStringArgs. + /// </summary> + /// <param name="row">The row.</param> + public ConvertFromStringArgs(IReaderRow row) + { + Row = row; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ConvertToString.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ConvertToString.cs new file mode 100644 index 0000000..478526e --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ConvertToString.cs @@ -0,0 +1,41 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that converts an object into a string. + /// </summary> + /// <typeparam name="TClass">The type of the class.</typeparam> + /// <param name="args">The args.</param> + /// <returns>The string.</returns> + public delegate string ConvertToString<TClass>(ConvertToStringArgs<TClass> args); + + /// <summary> + /// <see cref="ConvertToString{TClass}"/> args. + /// </summary> + /// <typeparam name="TClass">The value to convert.</typeparam> + public readonly struct ConvertToStringArgs<TClass> + { + /// <summary> + /// The value to convert. + /// </summary> + public readonly TClass Value; + + /// <summary> + /// Creates a new instance of ConvertToStringArgs{TClass}. + /// </summary> + /// <param name="value">The value to convert.</param> + public ConvertToStringArgs(TClass value) + { + Value = value; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/GetConstructor.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/GetConstructor.cs new file mode 100644 index 0000000..8678a5c --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/GetConstructor.cs @@ -0,0 +1,38 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that chooses the constructor to use for constructor mapping. + /// </summary> + public delegate ConstructorInfo GetConstructor(GetConstructorArgs args); + + /// <summary> + /// GetConstructor args. + /// </summary> + public readonly struct GetConstructorArgs + { + /// <summary> + /// The class type. + /// </summary> + public readonly Type ClassType; + + /// <summary> + /// Creates a new instance of GetConstructorArgs. + /// </summary> + /// <param name="classType">The class type.</param> + public GetConstructorArgs(Type classType) + { + ClassType = classType; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/GetDelimiter.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/GetDelimiter.cs new file mode 100644 index 0000000..2593200 --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/GetDelimiter.cs @@ -0,0 +1,44 @@ +using CsvHelper.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper.Delegates +{ + /// <summary> + /// Function that resolves the delimiter from the given text. + /// Returns null if no delimiter is found. + /// </summary> + /// <param name="args"></param> + /// <returns></returns> + public delegate string? GetDelimiter(GetDelimiterArgs args); + + /// <summary> + /// GetDelimiter args. + /// </summary> + public readonly struct GetDelimiterArgs + { + /// <summary> + /// The text to resolve the delimiter from. + /// </summary> + public readonly string Text; + + /// <summary> + /// The configuration. + /// </summary> + public readonly IParserConfiguration Configuration; + + /// <summary> + /// Creates an instance of GetDelimiterArgs. + /// </summary> + /// <param name="text">The text to resolve the delimiter from.</param> + /// <param name="configuration">The configuration.</param> + public GetDelimiterArgs(string text, IParserConfiguration configuration) + { + Text = text; + Configuration = configuration; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/GetDynamicPropertyName.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/GetDynamicPropertyName.cs new file mode 100644 index 0000000..4a761d6 --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/GetDynamicPropertyName.cs @@ -0,0 +1,44 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that gets the name to use for the property of the dynamic object. + /// </summary> + public delegate string GetDynamicPropertyName(GetDynamicPropertyNameArgs args); + + /// <summary> + /// GetDynamicPropertyName args. + /// </summary> + public readonly struct GetDynamicPropertyNameArgs + { + /// <summary> + /// The field index. + /// </summary> + public readonly int FieldIndex; + + /// <summary> + /// The context. + /// </summary> + public readonly CsvContext Context; + + /// <summary> + /// Creates a new instance of GetDynamicPropertyNameArgs. + /// </summary> + /// <param name="fieldIndex">The field index.</param> + /// <param name="context">The context.</param> + public GetDynamicPropertyNameArgs(int fieldIndex, CsvContext context) + { + FieldIndex = fieldIndex; + Context = context; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/HeaderValidated.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/HeaderValidated.cs new file mode 100644 index 0000000..07836d3 --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/HeaderValidated.cs @@ -0,0 +1,46 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that is called when a header validation check is ran. The default function + /// will throw a <see cref="ValidationException"/> if there is no header for a given member mapping. + /// You can supply your own function to do other things like logging the issue instead of throwing an exception. + /// </summary> + public delegate void HeaderValidated(HeaderValidatedArgs args); + + /// <summary> + /// HeaderValidated args. + /// </summary> + public readonly struct HeaderValidatedArgs + { + /// <summary> + /// The invalid headers. + /// </summary> + public readonly InvalidHeader[] InvalidHeaders; + + /// <summary> + /// The context. + /// </summary> + public readonly CsvContext Context; + + /// <summary> + /// Creates a new instance of HeaderValidatedArgs. + /// </summary> + /// <param name="invalidHeaders">The invalid headers.</param> + /// <param name="context">The context.</param> + public HeaderValidatedArgs(InvalidHeader[] invalidHeaders, CsvContext context) + { + InvalidHeaders = invalidHeaders; + Context = context; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/MissingFieldFound.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/MissingFieldFound.cs new file mode 100644 index 0000000..cb725fb --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/MissingFieldFound.cs @@ -0,0 +1,53 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that is called when a missing field is found. The default function will + /// throw a <see cref="MissingFieldException"/>. You can supply your own function to do other things + /// like logging the issue instead of throwing an exception. + /// </summary> + public delegate void MissingFieldFound(MissingFieldFoundArgs args); + + /// <summary> + /// MissingFieldFound args. + /// </summary> + public readonly struct MissingFieldFoundArgs + { + /// <summary> + /// The header names. + /// </summary> + public readonly string[]? HeaderNames; + + /// <summary> + /// The index. + /// </summary> + public readonly int Index; + + /// <summary> + /// The context. + /// </summary> + public readonly CsvContext Context; + + /// <summary> + /// Creates a new instance of MissingFieldFoundArgs. + /// </summary> + /// <param name="headerNames">The header names.</param> + /// <param name="index">The index.</param> + /// <param name="context">The context.</param> + public MissingFieldFoundArgs(string[]? headerNames, int index, CsvContext context) + { + HeaderNames = headerNames; + Index = index; + Context = context; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/PrepareHeaderForMatch.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/PrepareHeaderForMatch.cs new file mode 100644 index 0000000..061e493 --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/PrepareHeaderForMatch.cs @@ -0,0 +1,47 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that prepares the header field for matching against a member name. + /// The header field and the member name are both ran through this function. + /// You should do things like trimming, removing whitespace, removing underscores, + /// and making casing changes to ignore case. + /// </summary> + public delegate string PrepareHeaderForMatch(PrepareHeaderForMatchArgs args); + + /// <summary> + /// PrepareHeaderForMatch args. + /// </summary> + public readonly struct PrepareHeaderForMatchArgs + { + /// <summary> + /// The header. + /// </summary> + public readonly string Header; + + /// <summary> + /// The field index. + /// </summary> + public readonly int FieldIndex; + + /// <summary> + /// Creates a new instance of PrepareHeaderForMatchArgs. + /// </summary> + /// <param name="header">The header.</param> + /// <param name="fieldIndex">The field index.</param> + public PrepareHeaderForMatchArgs(string header, int fieldIndex) + { + Header = header; + FieldIndex = fieldIndex; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ReadingExceptionOccurred.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ReadingExceptionOccurred.cs new file mode 100644 index 0000000..c3737ef --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ReadingExceptionOccurred.cs @@ -0,0 +1,40 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that is called when a reading exception occurs. + /// The default function will re-throw the given exception. If you want to ignore + /// reading exceptions, you can supply your own function to do other things like + /// logging the issue. + /// </summary> + public delegate bool ReadingExceptionOccurred(ReadingExceptionOccurredArgs args); + + /// <summary> + /// ReadingExceptionOccurred args. + /// </summary> + public readonly struct ReadingExceptionOccurredArgs + { + /// <summary> + /// The exception. + /// </summary> + public readonly CsvHelperException Exception; + + /// <summary> + /// Creates a new instance of ReadingExceptionOccurredArgs. + /// </summary> + /// <param name="exception">The exception.</param> + public ReadingExceptionOccurredArgs(CsvHelperException exception) + { + Exception = exception; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ReferenceHeaderPrefix.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ReferenceHeaderPrefix.cs new file mode 100644 index 0000000..d42d49f --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ReferenceHeaderPrefix.cs @@ -0,0 +1,44 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that will return the prefix for a reference header. + /// </summary> + public delegate string ReferenceHeaderPrefix(ReferenceHeaderPrefixArgs args); + + /// <summary> + /// ReferenceHeaderPrefix args. + /// </summary> + public readonly struct ReferenceHeaderPrefixArgs + { + /// <summary> + /// The member type. + /// </summary> + public readonly Type MemberType; + + /// <summary> + /// The member name. + /// </summary> + public readonly string MemberName; + + /// <summary> + /// Creates a new instance of ReferenceHeaderPrefixArgs. + /// </summary> + /// <param name="memberType">The member type.</param> + /// <param name="memberName">The member name.</param> + public ReferenceHeaderPrefixArgs(Type memberType, string memberName) + { + MemberType = memberType; + MemberName = memberName; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ShouldQuote.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ShouldQuote.cs new file mode 100644 index 0000000..ab84ba3 --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ShouldQuote.cs @@ -0,0 +1,51 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that is used to determine if a field should get quoted when writing. + /// </summary> + public delegate bool ShouldQuote(ShouldQuoteArgs args); + + /// <summary> + /// ShouldQuote args. + /// </summary> + public readonly struct ShouldQuoteArgs + { + /// <summary> + /// The field. + /// </summary> + public readonly string Field; + + /// <summary> + /// The field type. + /// </summary> + public readonly Type FieldType; + + /// <summary> + /// The row. + /// </summary> + public readonly IWriterRow Row; + + /// <summary> + /// Creates a new instance of ShouldQuoteArgs. + /// </summary> + /// <param name="field">The field.</param> + /// <param name="fieldType">The field type.</param> + /// <param name="row">The row.</param> + public ShouldQuoteArgs(string field, Type fieldType, IWriterRow row) + { + Field = field; + FieldType = fieldType; + Row = row; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ShouldSkipRecord.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ShouldSkipRecord.cs new file mode 100644 index 0000000..cf87633 --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ShouldSkipRecord.cs @@ -0,0 +1,37 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that determines whether to skip the given record or not. + /// </summary> + public delegate bool ShouldSkipRecord(ShouldSkipRecordArgs args); + + /// <summary> + /// ShouldSkipRecord args. + /// </summary> + public readonly struct ShouldSkipRecordArgs + { + /// <summary> + /// The record. + /// </summary> + public readonly IReaderRow Row; + + /// <summary> + /// Creates a new instance of ShouldSkipRecordArgs. + /// </summary> + /// <param name="row">The row.</param> + public ShouldSkipRecordArgs(IReaderRow row) + { + Row = row; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ShouldUseConstructorParameters.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ShouldUseConstructorParameters.cs new file mode 100644 index 0000000..cfbacd5 --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/ShouldUseConstructorParameters.cs @@ -0,0 +1,38 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that determines if constructor parameters should be used to create + /// the class instead of the default constructor and members. + /// </summary> + public delegate bool ShouldUseConstructorParameters(ShouldUseConstructorParametersArgs args); + + /// <summary> + /// ShouldUseConstructorParameters args. + /// </summary> + public readonly struct ShouldUseConstructorParametersArgs + { + /// <summary> + /// The parameter type. + /// </summary> + public readonly Type ParameterType; + + /// <summary> + /// Creates a new instance of ShouldUseConstructorParametersArgs. + /// </summary> + /// <param name="parameterType">The parameter type.</param> + public ShouldUseConstructorParametersArgs(Type parameterType) + { + ParameterType = parameterType; + } + } +} diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/Validate.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/Validate.cs new file mode 100644 index 0000000..b2a42ea --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Delegates/Validate.cs @@ -0,0 +1,53 @@ +// Copyright 2009-2022 Josh Close +// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. +// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. +// https://github.com/JoshClose/CsvHelper +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CsvHelper +{ + /// <summary> + /// Function that validates a field. + /// </summary> + /// <param name="args">The args.</param> + /// <returns><c>true</c> if the field is valid, otherwise <c>false</c>.</returns> + public delegate bool Validate(ValidateArgs args); + + /// <summary> + /// Function that gets the exception message when validation fails. + /// </summary> + /// <param name="args">The args.</param> + /// <returns>The exception message.</returns> + public delegate string ValidateMessage(ValidateArgs args); + + /// <summary> + /// Validate args. + /// </summary> + public readonly struct ValidateArgs + { + /// <summary> + /// The field. + /// </summary> + public readonly string Field; + + /// <summary> + /// The row. + /// </summary> + public readonly IReaderRow Row; + + /// <summary> + /// Creates a new instance of ValidateArgs. + /// </summary> + /// <param name="field">The field.</param> + /// <param name="row">The row.</param> + public ValidateArgs(string field, IReaderRow row) + { + Field = field; + Row = row; + } + } +} |