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 --- .../Configuration/MemberNameCollection.cs | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 ThirdParty/CsvHelper-master/src/CsvHelper/Configuration/MemberNameCollection.cs (limited to 'ThirdParty/CsvHelper-master/src/CsvHelper/Configuration/MemberNameCollection.cs') diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper/Configuration/MemberNameCollection.cs b/ThirdParty/CsvHelper-master/src/CsvHelper/Configuration/MemberNameCollection.cs new file mode 100644 index 0000000..fb9db4a --- /dev/null +++ b/ThirdParty/CsvHelper-master/src/CsvHelper/Configuration/MemberNameCollection.cs @@ -0,0 +1,98 @@ +// 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.Collections; +using System.Collections.Generic; + +namespace CsvHelper.Configuration +{ + /// + /// A collection that holds member names. + /// + public class MemberNameCollection : IEnumerable + { + private readonly List names = new List(); + + /// + /// Gets the name at the given index. If a prefix is set, + /// it will be prepended to the name. + /// + /// + /// + public string this[int index] + { + get { return Prefix + names[index]; } + set { names[index] = value; } + } + + /// + /// Gets the prefix to use for each name. + /// + public string Prefix { get; set; } + + /// + /// Gets the raw list of names without + /// the prefix being prepended. + /// + public List Names => names; + + /// + /// Gets the count. + /// + public int Count => names.Count; + + /// + /// Adds the given name to the collection. + /// + /// The name to add. + public void Add(string name) + { + names.Add(name); + } + + /// + /// Clears all names from the collection. + /// + public void Clear() + { + names.Clear(); + } + + /// + /// Adds a range of names to the collection. + /// + /// The range to add. + public void AddRange(IEnumerable names) + { + this.names.AddRange(names); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// + /// A that can be used to iterate through the collection. + /// + /// 1 + public IEnumerator GetEnumerator() + { + for (var i = 0; i < names.Count; i++) + { + yield return this[i]; + } + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// + /// 2 + IEnumerator IEnumerable.GetEnumerator() + { + return names.GetEnumerator(); + } + } +} -- cgit v1.1-26-g67d0