Skip to content

Instantly share code, notes, and snippets.

View sheastrickland's full-sized avatar

Shea Strickland sheastrickland

View GitHub Profile
@sheastrickland
sheastrickland / CloudModuleBootstrapper.cs
Created February 16, 2015 00:33
ConfigInjector, support Autofac.Module settings and bootstrapping into IContainer
using System;
using Autofac;
namespace Syringe
{
/// <summary>
/// Bootstrapper, which obtains the dynamic CloudModule setting and loads the module into the Autofac Container.
/// </summary>
/// <remarks>
/// This required IBootstrapPostContainer, as it required access to the IContainer instance. IStartable runs before the instance is available.
@sheastrickland
sheastrickland / FormUrlEncodedPairs.cs
Created August 8, 2014 01:06
FormUrlEncodedPairs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
namespace Tests
@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";
@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 / 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 / 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)
{
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 / 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);
}
@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 / 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; }