Skip to content

Instantly share code, notes, and snippets.

View sheastrickland's full-sized avatar

Shea Strickland sheastrickland

View GitHub Profile
@sheastrickland
sheastrickland / AbcPdfDocumentGenerator.cs
Created March 30, 2011 09:10
AbcPdf in ASP.Net Mvc
public class AbcPdfDocumentGenerator : IDocumentGenerator
{
public string ContentType
{
get { return "application/pdf"; }
}
public string FileExtension
{
get { return "pdf"; }
@sheastrickland
sheastrickland / ControllerContextHost.cs
Created April 11, 2011 22:33
Windsor MvcFacility - Early hacks
using System;
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
namespace VMS.Domain.WindsorMvcFacility
{
public class ControllerContextHost
{
private ControllerBase controller;
@sheastrickland
sheastrickland / AlternateGroupBys.cs
Created July 13, 2011 11:54
Alternate GroupBy's
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Slumber.Tests
{
public class MagicData
{
public Department[] Departments { get; set; }
@sheastrickland
sheastrickland / Test.cs
Created November 16, 2011 11:32
Autofac Registration Examples for Resolving specific types
using Autofac;
using Autofac.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Testage
{
[TestClass]
public abstract class ConcernForResolvingLoggers
{
protected ContainerBuilder Builder;
@sheastrickland
sheastrickland / IRedirectProcessor.cs
Created March 7, 2012 06:14
Simple server-side solution to jQuery Mobile + Ajax request + Redirect being transparently followed and not updating the data-url / page
public interface IRedirectProcessor
{
string Process(ResultExecutedContext context);
}
public class LazyActionResult : ActionResult
{
readonly Func<ActionResult> _innerResult;
ActionResult _cachedResult;
public LazyActionResult(Func<ActionResult> innerResult)
{
if (innerResult == null) throw new ArgumentNullException("innerResult");
_innerResult = innerResult;
}
@sheastrickland
sheastrickland / Transpose.cs
Last active December 20, 2015 15:28
Mapping hack Dictionary - Death to switch statements!
using System;
using System.Collections.Generic;
using System.Linq;
namespace Utils
{
public class Transpose<TKey, TValue> : Dictionary<TKey, Func<TValue>>
{
public IEnumerable<TValue> Intersect(IEnumerable<TKey> keys)
{
@sheastrickland
sheastrickland / LanguageExtentions.cs
Last active August 29, 2015 13:57
Language extensions like .Safe, .Curry etc
using System;
using System.Collections.Generic;
namespace Awesomeness
{
public static class LanguageExtensions
{
public static TR? Safe<T, TR>(this T? target, Func<T, TR> accessor)
where T : struct where TR : struct
{
@sheastrickland
sheastrickland / DbUp.csproj
Created April 29, 2014 06:28
DbUp Compile error for SQL scripts which are not embedded
<Target Name="AfterBuild">
<Message Text="@(Content)" Importance="high" Condition="%(Content.Extension) == '.sql'" />
<Error Condition="%(Content.Extension) == '.sql'" Text="Nothing should be marked as Content, check your scripts are marked as Embedded Resource" />
</Target>
@sheastrickland
sheastrickland / CorrelationContext.cs
Created June 12, 2014 10:44
CorrelationContext - For help correlating messages between processes and consumers
using System;
using System.Collections.Generic;
using System.Runtime.Remoting.Messaging;
namespace Nimble.Messaging
{
public static class CorrelationContext
{
public const string RequestIdKey = "Correlation.RequestId";
public const string MessageIdKey = "Correlation.MessageId";