Skip to content

Instantly share code, notes, and snippets.

View rdingwall's full-sized avatar

Richard Dingwall rdingwall

View GitHub Profile
@rdingwall
rdingwall / FtpClientTests.cs
Created November 14, 2011 21:14
Tests for my URI ctor patch for System.Net.FtpClient
using System;
using System.Net.FtpClient;
using NUnit.Framework;
namespace System.Net.FtpClient.Tests
{
public class FtpClientTests
{
[TestFixture]
public class when_constructing
@rdingwall
rdingwall / ConnectionStringSettingsCollectionExtensions.cs
Created November 3, 2011 14:08
Rich's handy C# Extension Methods
// ReSharper disable CheckNamespace
namespace System.Configuration
// ReSharper restore CheckNamespace
{
public static class ConnectionStringSettingsCollectionExtensions
{
// Connection strings by default just return null. We want something
// a bit more snappy.
public static string GetOrThrow(this ConnectionStringSettingsCollection connectionStrings, string name)
{
@rdingwall
rdingwall / gist:1316612
Created October 26, 2011 15:01
Visual Studio Regex to remove Code Contracts and replace with standard if/throw
Find / replace
Contract.Requires\<ArgumentNullException\>\(!String.IsNullOr(Empty|WhiteSpace)\({:i}\)\);
if (String.IsNullOrWhiteSpace(\1)) throw new ArgumentException("\1 was null or empty.", "\1");
Contract\.Requires\<ArgumentNullException\>\({:i} \!\= null, .+\)\;
if (\1 == null) throw new ArgumentNullException("\1");
@rdingwall
rdingwall / InMemoryHostWithCustomResolver.cs
Created September 1, 2011 10:08
OpenRasta InMemoryHost that allows setting a custom resolver. Workaround for openrasta-stable issue 24
using System;
using System.Linq;
using System.Reflection;
using OpenRasta.Configuration;
using OpenRasta.DI;
// ReSharper disable CheckNamespace
namespace OpenRasta.Hosting.InMemory
// ReSharper restore CheckNamespace
{