This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var numbers = LoadNumbersUsingList(1, 10); | |
WriteNumbers(numbers); | |
numbers = LoadNumbersUsingYield(1, 10); | |
WriteNumbers(numbers); | |
Console.ReadLine(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static StringBuilder AsMarkdownTable(this DataTable source) | |
{ | |
StringBuilder sb = new StringBuilder(); | |
foreach (DataColumn column in source.Columns) | |
sb.Append("|").Append(column.ColumnName.Trim()); | |
sb.AppendLine("|"); | |
for (int i = 0; i < source.Columns.Count; i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomBindingList<T> : BindingList<T> | |
{ | |
private bool isSorting; | |
/// <summary> | |
/// Raised when the list is sorted. | |
/// </summary> | |
public event EventHandler Sorted; | |
public CustomBindingList() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FormattedXmlWriterTraceListener : XmlWriterTraceListener | |
{ | |
#region Fields | |
private XmlTextWriter xmlWriter; | |
private Process currentProcess; | |
private TextWriter writer; | |
private Stream stream; | |
private string fileName; | |
private object writerLock = new object(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConsoleColorContext : IDisposable | |
{ | |
private ConsoleColor backupBackgroundColor; | |
private ConsoleColor backupForegroundColor; | |
private ConsoleColorContext() | |
{ | |
this.backupForegroundColor = Console.ForegroundColor; | |
this.backupBackgroundColor = Console.BackgroundColor; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataReaderEnumerable : IEnumerable<IDataReader>, IDisposable | |
{ | |
public IDataReader DataReader { get; private set; } | |
private bool enumerated = false; | |
public DataReaderEnumerable(IDataReader dataReader) | |
{ | |
this.DataReader = dataReader; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TimeSpanInterval | |
{ | |
private readonly Func<TimeSpan, double> fromTimeSpan; | |
private readonly Func<double, TimeSpan> toTimeSpan; | |
private TimeSpanInterval(string name, Func<double, TimeSpan> toTimeSpan, Func<TimeSpan, double> fromTimeSpan) | |
{ | |
this.Name = name; | |
this.toTimeSpan = toTimeSpan; | |
this.fromTimeSpan = fromTimeSpan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Argument | |
{ | |
public Argument(string prefix) | |
: this(prefix, null) | |
{ | |
} | |
public Argument(string prefix, IEnumerable<string> values) | |
{ | |
this.Values = new List<string>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup> | |
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir> | |
</PropertyGroup> | |
<PropertyGroup> | |
<xUnitPackageVersion>2.1.0</xUnitPackageVersion> | |
<PackageDir>$(SolutionDir)packages\xunit.runner.msbuild.$(xUnitPackageVersion)\</PackageDir> | |
<NUnitXslFile>$(PackageDir)build\portable-net45+win8+wp8+wpa81\NUnitXml.xslt</NUnitXslFile> | |
<TestResultFileXUnit>$(SolutionDir)TestResults.xunit.xml</TestResultFileXUnit> |