Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DbEnumerator.cs
Go to the documentation of this file.
4
5namespace System.Data.Common;
6
8{
10 {
11 private readonly int _ordinal;
12
13 private readonly Type _type;
14
15 public override Type ComponentType => typeof(IDataRecord);
16
17 public override bool IsReadOnly => true;
18
19 public override Type PropertyType => _type;
20
21 internal DbColumnDescriptor(int ordinal, string name, Type type)
22 : base(name, null)
23 {
24 _ordinal = ordinal;
25 _type = type;
26 }
27
28 public override bool CanResetValue(object component)
29 {
30 return false;
31 }
32
33 public override object GetValue(object component)
34 {
35 return ((IDataRecord)component)[_ordinal];
36 }
37
38 public override void ResetValue(object component)
39 {
40 throw ADP.NotSupported();
41 }
42
43 public override void SetValue(object component, object value)
44 {
45 throw ADP.NotSupported();
46 }
47
48 public override bool ShouldSerializeValue(object component)
49 {
50 return false;
51 }
52 }
53
55
57
59
61
63
64 private readonly bool _closeReader;
65
66 public object Current => _current;
67
69 {
70 if (reader == null)
71 {
72 throw ADP.ArgumentNull("reader");
73 }
74 _reader = reader;
75 }
76
77 public DbEnumerator(IDataReader reader, bool closeReader)
78 {
79 if (reader == null)
80 {
81 throw ADP.ArgumentNull("reader");
82 }
83 _reader = reader;
84 _closeReader = closeReader;
85 }
86
88 : this((IDataReader)reader)
89 {
90 }
91
92 public DbEnumerator(DbDataReader reader, bool closeReader)
93 : this((IDataReader)reader, closeReader)
94 {
95 }
96
97 public bool MoveNext()
98 {
99 if (_schemaInfo == null)
100 {
102 }
103 _current = null;
104 if (_reader.Read())
105 {
106 object[] values = new object[_schemaInfo.Length];
109 return true;
110 }
111 if (_closeReader)
112 {
113 _reader.Close();
114 }
115 return false;
116 }
117
118 [EditorBrowsable(EditorBrowsableState.Never)]
119 public void Reset()
120 {
121 throw ADP.NotSupported();
122 }
123
124 private void BuildSchemaInfo()
125 {
126 int fieldCount = _reader.FieldCount;
127 string[] array = new string[fieldCount];
128 for (int i = 0; i < fieldCount; i++)
129 {
130 array[i] = _reader.GetName(i);
131 }
133 SchemaInfo[] array2 = new SchemaInfo[fieldCount];
135 for (int j = 0; j < array2.Length; j++)
136 {
137 SchemaInfo schemaInfo = default(SchemaInfo);
138 schemaInfo.name = _reader.GetName(j);
139 schemaInfo.type = _reader.GetFieldType(j);
140 schemaInfo.typeName = _reader.GetDataTypeName(j);
141 array3[j] = new DbColumnDescriptor(j, array[j], schemaInfo.type);
142 array2[j] = schemaInfo;
143 }
144 _schemaInfo = array2;
147 }
148}
static ArgumentNullException ArgumentNull(string parameter)
Definition ADP.cs:699
static NotSupportedException NotSupported()
Definition ADP.cs:753
static void BuildSchemaTableInfoTableNames(string[] columnNameArray)
Definition ADP.cs:592
DbColumnDescriptor(int ordinal, string name, Type type)
override void SetValue(object component, object value)
override void ResetValue(object component)
override bool ShouldSerializeValue(object component)
override object GetValue(object component)
override bool CanResetValue(object component)
DbEnumerator(IDataReader reader)
DbEnumerator(DbDataReader reader)
DbEnumerator(IDataReader reader, bool closeReader)
PropertyDescriptorCollection _descriptors
DbEnumerator(DbDataReader reader, bool closeReader)
string GetName(int i)
string GetDataTypeName(int i)
Type GetFieldType(int i)
int GetValues(object[] values)