Skip to content

Commit d1724b5

Browse files
committed
2016-11-11
- Upgrading projects to .NET 4.6.2 - Fixing code completion after = operator - Increasing ShortStringSize in App.config - Fixing AboutForm - Fixing DbColumn
1 parent ec12d48 commit d1724b5

File tree

25 files changed

+312
-142
lines changed

25 files changed

+312
-142
lines changed

DataCommander.Foundation/Collections/ReadOnlyNonUniqueSortedList.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public ReadOnlyNonUniqueSortedList(
6969
///
7070
/// </summary>
7171
[Pure]
72-
public int Count => this.groups != null ? this.groups.Count : 0;
72+
public int Count => this.groups?.Count ?? 0;
7373

7474
/// <summary>
7575
///
@@ -103,6 +103,22 @@ public IReadOnlyList<TValue> this[TKey key]
103103
}
104104
}
105105

106+
/// <summary>
107+
///
108+
/// </summary>
109+
/// <returns></returns>
110+
public IEnumerable<IReadOnlyList<TValue>> GetGroups()
111+
{
112+
int lastGroupIndex = this.groups.Count - 1;
113+
for (int groupIndex = 0; groupIndex <= lastGroupIndex; ++groupIndex)
114+
{
115+
int valueStartIndex = this.groups[groupIndex];
116+
int valueNextStartIndex = groupIndex < lastGroupIndex ? this.groups[groupIndex + 1] : this.values.Count;
117+
int valueCount = valueNextStartIndex - valueStartIndex;
118+
yield return new ReadOnlyListSegment<TValue>(this.values, valueStartIndex, valueCount);
119+
}
120+
}
121+
106122
#endregion
107123

108124
#region Public Methods
@@ -129,7 +145,7 @@ private void InitializeGroups()
129145
#region Create
130146

131147
int notEqualsCount = this.values.SelectPreviousAndCurrentKey(this.keySelector).Count(k => comparison(k.Previous, k.Current) != 0);
132-
int smallArrayMaxLength = LargeObjectHeap.GetSmallArrayMaxLength(sizeof (int));
148+
int smallArrayMaxLength = LargeObjectHeap.GetSmallArrayMaxLength(sizeof(int));
133149
int itemCount = notEqualsCount + 1;
134150
var segmentedArrayBuilder = new SegmentedArrayBuilder<int>(itemCount, smallArrayMaxLength);
135151

DataCommander.Foundation/Configuration/ConfigurationNodeTree.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void Save(XmlWriter xmlWriter, string sectionName)
3939
xmlWriter.WriteStartElement(sectionName);
4040
ConfigurationWriter.Write(xmlWriter, this.rootNode.Attributes);
4141

42-
foreach (ConfigurationNode childNode in this.rootNode.ChildNodes)
42+
foreach (var childNode in this.rootNode.ChildNodes)
4343
{
4444
ConfigurationWriter.WriteNode(xmlWriter, childNode);
4545
}
@@ -79,17 +79,17 @@ public ConfigurationNode SelectNode(string path)
7979
this.rootNode = new ConfigurationNode(null);
8080
}
8181

82-
ConfigurationNode node = this.rootNode;
82+
var node = this.rootNode;
8383

8484
if (path != null)
8585
{
86-
string[] nodeNames = path.Split(ConfigurationNode.Delimiter);
86+
var nodeNames = path.Split(ConfigurationNode.Delimiter);
8787

88-
for (int i = 0; i < nodeNames.Length; i++)
88+
for (var i = 0; i < nodeNames.Length; i++)
8989
{
90-
string childNodeName = nodeNames[i];
90+
var childNodeName = nodeNames[i];
9191
ConfigurationNode childNode;
92-
bool contains = node.ChildNodes.TryGetValue(childNodeName, out childNode);
92+
var contains = node.ChildNodes.TryGetValue(childNodeName, out childNode);
9393

9494
if (!contains)
9595
{

DataCommander.Foundation/Configuration/ConfigurationReader.cs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private static Stream OpenStream(string configFileName)
3535

3636
if (true)
3737
{
38-
int count = 0;
38+
var count = 0;
3939

4040
while (true)
4141
{
@@ -101,7 +101,7 @@ private static Type GetType(string typeName)
101101
/// <returns></returns>
102102
private bool FindSection(string sectionName)
103103
{
104-
bool found = false;
104+
var found = false;
105105

106106
while (this.xmlReader.Read())
107107
{
@@ -120,17 +120,17 @@ private bool FindSection(string sectionName)
120120

121121
private object ReadAttributeValueArray(Type elementType)
122122
{
123-
List<object> list = new List<object>();
124-
bool go = !this.xmlReader.IsEmptyElement;
123+
var list = new List<object>();
124+
var go = !this.xmlReader.IsEmptyElement;
125125

126126
while (go && this.xmlReader.Read())
127127
{
128128
switch (this.xmlReader.NodeType)
129129
{
130130
case XmlNodeType.Element:
131131
{
132-
string valueStr = this.xmlReader["value"];
133-
object value = Convert.ChangeType(valueStr, elementType, this.formatProvider);
132+
var valueStr = this.xmlReader["value"];
133+
var value = Convert.ChangeType(valueStr, elementType, this.formatProvider);
134134
list.Add(value);
135135
}
136136

@@ -165,7 +165,7 @@ private object ReadAttributeValue(Type type)
165165

166166
if (typeCode == TypeCode.Byte)
167167
{
168-
string innerXml = this.xmlReader.ReadInnerXml();
168+
var innerXml = this.xmlReader.ReadInnerXml();
169169
value = System.Convert.FromBase64String(innerXml);
170170
}
171171
else
@@ -183,7 +183,7 @@ private object ReadAttributeValue(Type type)
183183
{
184184
while (this.xmlReader.Read())
185185
{
186-
bool isBreakable = false;
186+
var isBreakable = false;
187187
Trace.WriteLine(this.xmlReader.NodeType);
188188

189189
switch (this.xmlReader.NodeType)
@@ -208,14 +208,14 @@ private object ReadAttributeValue(Type type)
208208
}
209209
else if (type == typeof(XmlNode))
210210
{
211-
string innerXml = this.xmlReader.ReadInnerXml();
212-
XmlDocument document = new XmlDocument();
211+
var innerXml = this.xmlReader.ReadInnerXml();
212+
var document = new XmlDocument();
213213
document.LoadXml(innerXml);
214214
value = document.DocumentElement;
215215
}
216216
else
217217
{
218-
string innerXml = this.xmlReader.ReadInnerXml();
218+
var innerXml = this.xmlReader.ReadInnerXml();
219219
value = XmlSerializerHelper.Deserialize(innerXml, type);
220220
}
221221

@@ -228,7 +228,7 @@ private void AddError(
228228
Exception e)
229229
{
230230
string message2 = null;
231-
IXmlLineInfo lineInfo = this.xmlReader as IXmlLineInfo;
231+
var lineInfo = this.xmlReader as IXmlLineInfo;
232232

233233
if (lineInfo != null && lineInfo.HasLineInfo())
234234
{
@@ -245,7 +245,7 @@ private void AddError(
245245
private void ReadAttribute(ConfigurationNode node)
246246
{
247247
ConfigurationAttribute attribute = null;
248-
string name = this.xmlReader["name"];
248+
var name = this.xmlReader["name"];
249249
object value = null;
250250

251251
try
@@ -255,14 +255,14 @@ private void ReadAttribute(ConfigurationNode node)
255255
this.AddError(ErrorType.Warning, "name attribute not found", null);
256256
}
257257

258-
string typeName = this.xmlReader["type"];
259-
Type type = GetType(typeName);
258+
var typeName = this.xmlReader["type"];
259+
var type = GetType(typeName);
260260

261261
if (type != null)
262262
{
263-
string isNullStr = this.xmlReader["isNull"];
264-
bool isNull = false;
265-
string description = this.xmlReader["description"];
263+
var isNullStr = this.xmlReader["isNull"];
264+
var isNull = false;
265+
var description = this.xmlReader["description"];
266266

267267
if (isNullStr != null)
268268
{
@@ -278,7 +278,7 @@ private void ReadAttribute(ConfigurationNode node)
278278

279279
if (!isNull)
280280
{
281-
string valueStr = this.xmlReader["value"];
281+
var valueStr = this.xmlReader["value"];
282282

283283
try
284284
{
@@ -324,17 +324,17 @@ private void ReadAttribute(ConfigurationNode node)
324324

325325
private void Read(ConfigurationNode node, StringCollection fileNames)
326326
{
327-
string name = node.Name;
328-
bool endOfNode = this.xmlReader.IsEmptyElement;
327+
var name = node.Name;
328+
var endOfNode = this.xmlReader.IsEmptyElement;
329329

330330
if (name != null)
331331
{
332-
bool hasNext = this.xmlReader.MoveToFirstAttribute();
332+
var hasNext = this.xmlReader.MoveToFirstAttribute();
333333

334334
while (hasNext)
335335
{
336-
string attributeName = this.xmlReader.Name;
337-
string attributeValue = this.xmlReader.Value;
336+
var attributeName = this.xmlReader.Name;
337+
var attributeValue = this.xmlReader.Value;
338338

339339
if (attributeName == "name")
340340
{
@@ -345,7 +345,7 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
345345
}
346346
else
347347
{
348-
ConfigurationAttribute attribute = new ConfigurationAttribute(attributeName, attributeValue, null);
348+
var attribute = new ConfigurationAttribute(attributeName, attributeValue, null);
349349
node.Attributes.Add(attribute);
350350
}
351351

@@ -359,7 +359,7 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
359359
{
360360
case XmlNodeType.Element:
361361
{
362-
string elementName = this.xmlReader.Name;
362+
var elementName = this.xmlReader.Name;
363363

364364
switch (elementName)
365365
{
@@ -369,8 +369,8 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
369369

370370
case ConfigurationElementName.Node:
371371
{
372-
string nodeName = this.xmlReader.GetAttribute("name");
373-
ConfigurationNode childNode = new ConfigurationNode(nodeName);
372+
var nodeName = this.xmlReader.GetAttribute("name");
373+
var childNode = new ConfigurationNode(nodeName);
374374
node.AddChildNode(childNode);
375375
this.Read(childNode, fileNames);
376376
}
@@ -379,14 +379,14 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
379379

380380
case "include":
381381
{
382-
string fileName = this.xmlReader.GetAttribute("fileName");
382+
var fileName = this.xmlReader.GetAttribute("fileName");
383383
fileName = Environment.ExpandEnvironmentVariables(fileName);
384384

385385
var reader2 = new ConfigurationReader();
386-
ConfigurationNode includeNode = reader2.Read(fileName, this.sectionName, fileNames);
386+
var includeNode = reader2.Read(fileName, this.sectionName, fileNames);
387387
node.Attributes.Add(includeNode.Attributes);
388388

389-
foreach (ConfigurationNode childNode in includeNode.ChildNodes)
389+
foreach (var childNode in includeNode.ChildNodes)
390390
{
391391
node.AddChildNode(childNode);
392392
}
@@ -401,8 +401,8 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
401401

402402
default:
403403
{
404-
string nodeName = XmlConvert.DecodeName(elementName);
405-
ConfigurationNode childNode = new ConfigurationNode(nodeName);
404+
var nodeName = XmlConvert.DecodeName(elementName);
405+
var childNode = new ConfigurationNode(nodeName);
406406
node.AddChildNode(childNode);
407407
this.Read(childNode, fileNames);
408408
}
@@ -425,15 +425,15 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
425425

426426
private void InitCultureInfo()
427427
{
428-
string cultureInfo = this.xmlReader["cultureInfo"];
428+
var cultureInfo = this.xmlReader["cultureInfo"];
429429

430430
if (cultureInfo != null)
431431
{
432432
try
433433
{
434434
try
435435
{
436-
int culture = int.Parse(cultureInfo, CultureInfo.InvariantCulture);
436+
var culture = int.Parse(cultureInfo, CultureInfo.InvariantCulture);
437437
this.formatProvider = new CultureInfo(culture);
438438
}
439439
catch
@@ -468,7 +468,7 @@ public ConfigurationNode Read(
468468
StringCollection fileNames)
469469
{
470470
log.Trace("ConfigurationReader.Read({0},{1})...", configFilename, sectionName);
471-
long startTick = Stopwatch.GetTimestamp();
471+
var startTick = Stopwatch.GetTimestamp();
472472
this.xmlReader = xmlReader;
473473
this.fileName = configFilename;
474474
this.sectionName = sectionName;
@@ -477,11 +477,11 @@ public ConfigurationNode Read(
477477

478478
try
479479
{
480-
bool found = this.FindSection(sectionName);
480+
var found = this.FindSection(sectionName);
481481

482482
if (found)
483483
{
484-
XmlNodeType nodeType = xmlReader.MoveToContent();
484+
var nodeType = xmlReader.MoveToContent();
485485

486486
if (nodeType == XmlNodeType.Element)
487487
{
@@ -512,10 +512,10 @@ public ConfigurationNode Read(
512512
this.AddError(ErrorType.Error, null, e);
513513
}
514514

515-
long ticks = Stopwatch.GetTimestamp() - startTick;
515+
var ticks = Stopwatch.GetTimestamp() - startTick;
516516
message = $"{configFilename} loaded successfully in {StopwatchTimeSpan.ToString(ticks, 3)}.";
517517
LogLevel logLevel;
518-
IEnumerable<Error> source = this.errors.Where(e => e.Type == ErrorType.Error);
518+
var source = this.errors.Where(e => e.Type == ErrorType.Error);
519519

520520
if (source.Any())
521521
{
@@ -553,7 +553,7 @@ public ConfigurationNode Read(
553553
{
554554
ConfigurationNode node = null;
555555

556-
using (Stream stream = OpenStream(configFileName))
556+
using (var stream = OpenStream(configFileName))
557557
{
558558
if (stream != null)
559559
{
@@ -573,13 +573,13 @@ public ConfigurationNode Read(
573573
public ConfigurationNode Read(XmlReader xmlReader)
574574
{
575575
this.xmlReader = xmlReader;
576-
ConfigurationNode node = new ConfigurationNode(null);
577-
StringCollection fileNames = new StringCollection();
576+
var node = new ConfigurationNode(null);
577+
var fileNames = new StringCollection();
578578
this.Read(node, fileNames);
579579

580580
if (node.ChildNodes.Count == 1)
581581
{
582-
ConfigurationNode childNode = node.ChildNodes[0];
582+
var childNode = node.ChildNodes[0];
583583
node.RemoveChildNode(childNode);
584584
node = childNode;
585585
}

0 commit comments

Comments
 (0)