GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bytecode-api/BytecodeApi.CsvParser/CsvRow.cs at master · bytecode77/bytecode-api

Expand file tree

/

CsvRow.cs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
106 lines (100 loc) · 3.41 KB
/

CsvRow.cs

Copy path

File metadata and controls

106 lines (100 loc) · 3.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using BytecodeApi.Extensions;
using System.Collections;
using System.Diagnostics;
namespace BytecodeApi.CsvParser;
/// <summary>
/// Represents a row of a <see cref="CsvFile" />.
/// </summary>
[DebuggerDisplay($"{nameof(CsvRow)}: LineNumber = {{LineNumber}}, ErrorLine = {{ErrorLine}}, Cells: {{Count}}")]
public sealed class CsvRow : IReadOnlyCollection<CsvCell>
{
private readonly List<CsvCell> Cells;
/// <summary>
/// Gets or sets the <see cref="CsvCell" /> at the specified column index.
/// </summary>
/// <param name="index">The zero-based column index.</param>
public CsvCell this[int index]
{
get
{
Check.IndexOutOfRange(index, Count);
return Cells[index];
}
set
{
Check.IndexOutOfRange(index, Count);
Cells[index] = value;
}
}
/// <summary>
/// Gets or sets the <see cref="CsvCell" /> at the specified column name, represented as an Excel column name (like A, B, ... AA, AB, ...).
/// </summary>
/// <param name="column">A <see cref="string" /> specifying the one-based column index, represented as an Excel column name (like A, B, ... AA, AB, ...).</param>
public CsvCell this[string column]
{
get
{
Check.ArgumentNull(column);
Check.ArgumentEx.StringNotEmpty(column);
return this[Convert.FromExcelColumnString(column)];
}
set
{
Check.ArgumentNull(column);
Check.ArgumentEx.StringNotEmpty(column);
this[Convert.FromExcelColumnString(column)] = value;
}
}
/// <summary>
/// Gets the number of cells in this <see cref="CsvRow" />.
/// </summary>
public int Count => Cells.Count;
/// <summary>
/// Gets the one-based line number of this <see cref="CsvRow" /> object, if it was loaded from an existing CSV source. Returns -1, if the row has been manually initialized.
/// </summary>
public long LineNumber { get; internal set; }
/// <summary>
/// If the line could not be parsed, gets the <see cref="string" /> representing the original line, otherwise returns <see langword="null" />.
/// </summary>
public string? ErrorLine { get; internal set; }
/// <summary>
/// Initializes a new instance of the <see cref="CsvRow" /> class.
/// </summary>
public CsvRow()
{
Cells = [];
LineNumber = -1;
}
/// <summary>
/// Initializes a new instance of the <see cref="CsvRow" /> class with a collection of cells.
/// </summary>
/// <param name="cells">The collection of cells to be added to this <see cref="CsvRow" />.</param>
public CsvRow(params IEnumerable<CsvCell> cells) : this()
{
Check.ArgumentNull(cells);
Cells.AddRange(cells);
}
/// <summary>
/// Initializes a new instance of the <see cref="CsvRow" /> class with a collection of cells.
/// </summary>
/// <param name="cells">The collection of cells to be added to this <see cref="CsvRow" />, represented as <see cref="string" /> objects.</param>
public CsvRow(params IEnumerable<string> cells) : this()
{
Check.ArgumentNull(cells);
Cells.AddRange(cells.Select(cell => new CsvCell(cell)));
}
/// <summary>
/// Returns an enumerator that iterates through the <see cref="CsvRow" /> cell collection.
/// </summary>
/// <returns>
/// An enumerator that can be used to iterate through the <see cref="CsvRow" /> cell collection.
/// </returns>
public IEnumerator<CsvCell> GetEnumerator()
{
return Cells.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return Cells.GetEnumerator();
}
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.