Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Marble jsmarble

View GitHub Profile
@jsmarble
jsmarble / DataTable.AsMarkdownTable.cs
Last active Jan 17, 2017
Extension method to turn a DataTable into a Markdown table
View DataTable.AsMarkdownTable.cs
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++)
@jsmarble
jsmarble / CustomBindingList.cs
Last active Dec 19, 2016
Custom Sorting of BindingList<T>
View CustomBindingList.cs
public class CustomBindingList<T> : BindingList<T>
{
private bool isSorting;
/// <summary>
/// Raised when the list is sorted.
/// </summary>
public event EventHandler Sorted;
public CustomBindingList()
View FormattedXmlWriterTraceListener.cs
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();
View ConsoleColorContext.cs
public class ConsoleColorContext : IDisposable
{
private ConsoleColor backupBackgroundColor;
private ConsoleColor backupForegroundColor;
private ConsoleColorContext()
{
this.backupForegroundColor = Console.ForegroundColor;
this.backupBackgroundColor = Console.BackgroundColor;
}
View DataReaderEnumerable.cs
public class DataReaderEnumerable : IEnumerable<IDataReader>, IDisposable
{
public IDataReader DataReader { get; private set; }
private bool enumerated = false;
public DataReaderEnumerable(IDataReader dataReader)
{
this.DataReader = dataReader;
}
View TimeSpanInterval.cs
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;
@jsmarble
jsmarble / Argument.cs
Last active Apr 26, 2016
argument-parser
View Argument.cs
public class Argument
{
public Argument(string prefix)
: this(prefix, null)
{
}
public Argument(string prefix, IEnumerable<string> values)
{
this.Values = new List<string>();
@jsmarble
jsmarble / after.SolutionName.sln.targets
Last active Mar 14, 2016 — forked from coldacid/after.SolutionName.sln.targets
After-solution targets file for xUnit.net
View after.SolutionName.sln.targets
<?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>
You can’t perform that action at this time.