Skip to content

Instantly share code, notes, and snippets.

View melcloud's full-sized avatar

Yin Zhang melcloud

View GitHub Profile
@gregoryyoung
gregoryyoung / gist:7690486
Created November 28, 2013 11:31
updated to support actions to funcs
namespace crap
{
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
public class PartialAppPlayground
public class Result<T>
{
public bool IsSuccess { get; private set; }
public string ErrorMessage { get; private set; }
public IEnumerable<T> Results { get; private set; }
private Result()
{ }
public static Result<T> Success(IEnumerable<T> results)
@darrelmiller
darrelmiller / gist:8548166
Created January 21, 2014 20:54
How to tell Web API 2.1 to allow errors to propagate up the MessageHandler pipeline so all exceptions can be converted to HttpResponseMessages in one place.
class Program
{
static void Main(string[] args)
{
var server = WebApp.Start("http://localhost:1002/", (app) =>
{
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
config.Services.Replace(typeof(IExceptionHandler), new RethrowExceptionHandler());
@bradwilson
bradwilson / Cacheability.cs
Created January 23, 2014 20:53
Using chaining to create cached results in ASP.NET Web API v2
public enum Cacheability
{
NoCache,
Private,
Public,
}