aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CSV/CsvSource.cs
blob: ba7e458e6f47cc5d2b5bac947f2446f5a1a6b319 (plain)
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Collections.Concurrent;
using System.Threading.Tasks;

namespace Tango.CSV
{
    /// <summary>
    /// Represents a <see cref="CsvFile"/> source.
    /// </summary>
    public class CsvSource
    {
        public readonly TextReader TextReader;

        /// <summary>
        /// Performs an implicit conversion from <see cref="CsvFile"/> to <see cref="CsvSource"/>.
        /// </summary>
        /// <param name="csvFile">The CSV file.</param>
        /// <returns>
        /// The result of the conversion.
        /// </returns>
        public static implicit operator CsvSource(CsvFile csvFile)
        {
            return new CsvSource(csvFile);
        }

        /// <summary>
        /// Performs an implicit conversion from <see cref="System.String"/> to <see cref="CsvSource"/>.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>
        /// The result of the conversion.
        /// </returns>
        public static implicit operator CsvSource(string path)
        {
            return new CsvSource(path);
        }

        /// <summary>
        /// Performs an implicit conversion from <see cref="TextReader"/> to <see cref="CsvSource"/>.
        /// </summary>
        /// <param name="textReader">The text reader.</param>
        /// <returns>
        /// The result of the conversion.
        /// </returns>
        public static implicit operator CsvSource(TextReader textReader)
        {
            return new CsvSource(textReader);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CsvSource"/> class.
        /// </summary>
        /// <param name="textReader">The text reader.</param>
        public CsvSource(TextReader textReader)
        {
            this.TextReader = textReader;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CsvSource"/> class.
        /// </summary>
        /// <param name="stream">The stream.</param>
        public CsvSource(Stream stream)
        {
            this.TextReader = new StreamReader(stream);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CsvSource"/> class.
        /// </summary>
        /// <param name="path">The path.</param>
        public CsvSource(string path)
        {
            this.TextReader = new StreamReader(path);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CsvSource"/> class.
        /// </summary>
        /// <param name="csvFile">The CSV file.</param>
        public CsvSource(CsvFile csvFile)
        {
            this.TextReader = new StreamReader(csvFile.BaseStream);
        }
    }
}