Skip to content

Instantly share code, notes, and snippets.

View ianfnelson's full-sized avatar

Ian Nelson ianfnelson

View GitHub Profile
@ianfnelson
ianfnelson / GenericSorter.cs
Created March 28, 2014 20:57
Code for 2004 blog post A Generic Sorter For Strongly-Typed Collections
using System;
using System.Collections;
using System.Globalization;
using System.Reflection;
namespace IanNelson.Utilities
{
/// <SUMMARY>
/// A generic sorter, inheriting from IComparer,
/// intended to allow for the sorting of
/// strongly-typed collections on any named public property
@ianfnelson
ianfnelson / EmailPublisher.cs
Last active August 29, 2015 13:57
Code for 2004 blog post "Custom Email Publisher for Microsoft Exception Management Application Block"
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Reflection;
using System.Text;
using System.Web.Mail;
using Microsoft.ApplicationBlocks.ExceptionManagement;
namespace IanFNelson
{
@ianfnelson
ianfnelson / ControlPropertiesValid.cs
Created March 28, 2014 20:36
Gists for 2004 Blog Post "Inheriting From BaseValidator to Make Custom Validation Controls"
///
/// This method checks whether the control set in the
/// ControlToValidate property is valid.
///
/// Boolean indicating whether we have a valid ControlToValidate
protected override bool ControlPropertiesValid()
{
// Get the control we're trying to validate
Control ctrl = FindControl(ControlToValidate);
if (ctrl == null)
@ianfnelson
ianfnelson / TestFixture.cs
Created January 7, 2012 20:53
Test Domain Entities Contain Only Virtual Public Members
/// <summary>
/// This test is designed to catch those instances where we forget to mark public members on entities
/// as virtual - before NH complains at runtime.
///
/// Where classes implement properties from interfaces, the CLR will treat those properties
/// as virtual even when they have not explicitly been set as such (e.g. implementations of IEntity.Id)
/// so this test is not fool-proof. But it should help.
/// </summary>
[Test]
public void Convention_AllDomainEntitiesShouldContainOnlyVirtualMembers()
@ianfnelson
ianfnelson / gist:632368
Created October 18, 2010 15:15
Unit of Work
namespace Marshalls.Leads.DataAccess
{
using System;
using System.Collections.Generic;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using Marshalls.Leads.Facilities;
using Marshalls.Leads.Facilities.Configuration;
using NHibernate;
using NHibernate.Cfg;
@ianfnelson
ianfnelson / WindsorServiceLocator.cs
Created March 25, 2010 21:38
Windsor implementation of Common Service Locator
using System;
using System.Collections.Generic;
using Castle.Windsor;
using Microsoft.Practices.ServiceLocation;
/// <summary>
/// Adapts the behavior of the Windsor container to the common
/// IServiceLocator
/// </summary>
public class WindsorServiceLocator : ServiceLocatorImplBase
@ianfnelson
ianfnelson / AspNetCache.cs
Created March 25, 2010 21:35
Caching abstractions for DI and testing purposes
namespace IanFNelson.Utilities.Caching
{
using System;
using System.Web;
using System.Web.Caching;
public class AspNetCache : ICache
{
public object Get(string key)
{