Skip to content

Instantly share code, notes, and snippets.

View MattHoneycutt's full-sized avatar

Matt Honeycutt MattHoneycutt

View GitHub Profile
@MattHoneycutt
MattHoneycutt / DecorateThis.cs
Created September 9, 2012 21:12
StructureMap Decorator
public static class StructureMapDecoratorHelperExtension
{
public static DecoratorHelper<TTarget> Decorate<TTarget>(this SmartInstance<TTarget> instance)
{
return new DecoratorHelper<TTarget>(instance);
}
}
public class DecoratorHelper<TTarget>
@MattHoneycutt
MattHoneycutt / ModularConventionViewEngine.cs
Created May 2, 2013 02:09
A Razor view engine that supports several methods of organizing views and controllers within the same folder.
public class ModularConventionViewEngine : RazorViewEngine
{
//This needs to be initialized to the root namespace of your MVC project.
//Usually, the namespace of your Global.asax's codebehind will do the trick.
private static readonly string RootNamespace = typeof(MvcApplication).Namespace;
private static IEnumerable<string> GetPath(ControllerContext controllerContext, string viewName)
{
var paths = new List<string>();
using System.Web.Mvc;
namespace HeroicSupport.Web.Filters
{
public class StandardModelStateValidationAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (!filterContext.Controller.ViewData.ModelState.IsValid)
{
using SpecsFor;
public class OrderProcessorSpecs : SpecsFor<OrderProcessor>
{
[Test]
public void Order_submitted_successfully_Tests()
{
GetMockFor<IInventory>()
.Setup(i => i.IsQuantityAvailable("TestPart", 10))
.Returns(true)
.Verifiable();
using SpecsFor;
public class OrderProcessorSpecs : SpecsFor<OrderProcessor>
{
ProcessingResult _result;
protected override void Given()
{
GetMockFor<IInventory>()
.Setup(i => i.IsQuantityAvailable("TestPart", 10))
.Returns(true)
@MattHoneycutt
MattHoneycutt / gist:97342b8f79e1cc378d14
Created October 24, 2014 15:50
Create a new git repo with a standard .gitignore
$StandardGitIgnoreFile = Resolve-Path ".\std.gitignore"
function Git-InitStandard() {
git init .
Copy-Item $StandardGitIgnoreFile ".\.gitignore"
Write-Host "Added standard gitignore file."
}
<#
This assumes you have a file next to your Powershell profile (where this function is defined) named std.gitignore. Here's what's in mine:
@MattHoneycutt
MattHoneycutt / GridTag.cs
Created November 14, 2015 02:59
Updated MvcGridDirective and GridTag that allows for cell templates.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web.UI;
using HeroicCRM.Web.Utilities;
using HtmlTags;
namespace HeroicCRM.Web.Helpers
{