Skip to content

Instantly share code, notes, and snippets.

View stevenkuhn's full-sized avatar

Steven Kuhn stevenkuhn

View GitHub Profile
@stevenkuhn
stevenkuhn / ICommunicationObjectExtensions.cs
Created January 22, 2012 05:39
Disposing a WCF Proxy Using an Extension Method
public static class ICommunicationObjectExtensions
{
public static void TryCloseOrAbort(this ICommunicationObject obj)
{
if (obj != null)
{
if (obj.State != CommunicationState.Faulted &&
obj.State != CommunicationState.Closed)
{
try { obj.Close(); }
@stevenkuhn
stevenkuhn / gist:1655779
Created January 22, 2012 05:34
Extension Method to Sort ListItems in a ListControl in ASP.NET
public static void Sort(this ListItemCollection items)
{
IList<ListItem> itemList = new List<ListItem>();
foreach (ListItem item in items)
itemList.Add(item);
IEnumerable<ListItem> itemEnum =
from item in itemList orderby item.Text select item;
items.Clear();
@stevenkuhn
stevenkuhn / ConfigurationPropertyAttribute.cs
Created January 5, 2012 16:46
ConfigurationPropertyAttribute from nexuspwn
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class ConfigurationPropertyAttribute : Attribute, IComparable<ConfigurationPropertyAttribute>
{
public ConfigurationPropertyAttribute(string displayName)
{
DisplayName = displayName;
}
public string DisplayName { get; set; }