Skip to content

Instantly share code, notes, and snippets.

View rmacfie's full-sized avatar
😎

Robert Macfie rmacfie

😎
  • Stockholm, Sweden
View GitHub Profile
@rmacfie
rmacfie / StructureMapNancyBootstrapper.cs
Last active August 29, 2015 14:00
Nancy bootstrapper with StructureMap (without just in time registrations)
public class StructureMapNancyBootstrapper : StructureMapNancyBootstrapperBase
{
public StructureMapNancyBootstrapper() : base(typeof(MyModule).Assembly)
{
}
protected override IContainer GetApplicationContainer()
{
return new Container();
}
@rmacfie
rmacfie / gist:4512293
Last active December 10, 2015 23:49
StructureMap + MVC4 + WebApi
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http.Dependencies;
using StructureMap;
public class StructureMapResolver : IDependencyScope, IDependencyResolver
{
private readonly IContainer _container;
private readonly bool _isContainerOwner;
@rmacfie
rmacfie / Object.cshtml
Created July 31, 2012 20:49
Default object Editor Template ported to Razor (Asp.Net Mvc)
@{
Func<ModelMetadata, bool> shouldShow = metadata =>
{
return metadata.ShowForEdit
//&& metadata.ModelType != typeof(System.Data.EntityState)
&& !metadata.IsComplexType
&& !ViewData.TemplateInfo.Visited(metadata);
};
}
@if (ViewData.TemplateInfo.TemplateDepth > 1)
@rmacfie
rmacfie / C# hash generator
Created February 15, 2011 19:21
Generate Md5 and SHA hashes in C#.NET.
public static class CryptographyExtensions
{
/// <summary>
/// Calculates the MD5 hash for the given string.
/// </summary>
/// <returns>A 32 char long MD5 hash.</returns>
public static string GetHashMd5(this string input)
{
return ComputeHash(input, new MD5CryptoServiceProvider());
}