Skip to content

Instantly share code, notes, and snippets.

jsmarble / DataTable.AsMarkdownTable.cs
Last active Mar 10, 2021
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)
for (int i = 0; i < source.Columns.Count; i++)
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 / Argument.cs
Last active Apr 26, 2016
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 / after.SolutionName.sln.targets
Last active Mar 14, 2016 — forked from coldacid/after.SolutionName.sln.targets
After-solution targets file for
View after.SolutionName.sln.targets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Test" xmlns="">
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir>