Skip to content

Instantly share code, notes, and snippets.

using System.Reflection;
using log4net;
namespace BasilBee.Infrastructure.Logging {
public class LoggingService : ILoggingService
{
// ReSharper disable InconsistentNaming
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// ReSharper restore InconsistentNaming
public static IHtmlString Resource(this HtmlHelper htmlHelper, Func<object, dynamic> template, string type)
{
if (htmlHelper.ViewContext.HttpContext.Items[type] != null) ((List<Func<object, dynamic>>)htmlHelper.ViewContext.HttpContext.Items[type]).Add(template);
else htmlHelper.ViewContext.HttpContext.Items[type] = new List<Func<object, dynamic>>() { template };
return new HtmlString(String.Empty);
}
public static IHtmlString RenderResources(this HtmlHelper htmlHelper, string type)
{
//at the top of _Layout.cshtml
@RenderSection("Styles",false)
@Html.RenderResources(ResourceType.Css)
//at the bottom of _Layout.cshtml
@RenderSection("Scripts",false)
@Html.RenderResources(ResourceType.Js)
//for style sheets
@Html.Resource(@<link href="@Url.Content("~/Content/productSummary.css")" rel="stylesheet" />, ResourceType.Css)
//for script files
@Html.Resource(@<script src="@Url.Content("~/js/productSummary.js")" type="text/javascript" ></script>, ResourceType.Js)
public static class ResourceType
{
public const string Css = "css";
public const string Js = "js";
}
@taylorc
taylorc / gist:5236289
Created March 25, 2013 10:39
Set Up Chocolatey at the Command Prompt
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
@taylorc
taylorc / gist:5236315
Created March 25, 2013 10:45
Install Git and Git Flow
cinst msysgit
cinst git
cinst poshgit
cinst git-flow-dependencies
@taylorc
taylorc / gist:5241772
Created March 25, 2013 23:15
Steps to install gift flow on windows
# clone git flow to appropriate directory
> git clone --recursive git://github.com/nvie/gitflow.git
# change directory to gitflow
> cd gitflow
# Run the msysgit-install script with the location as a parameter.
> contrib\msysgit-install.cmd "C:\Users\USER_NAME\AppData\Local\GitHub\PortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7"
# Note: Replace PortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7 with the name of your directory; you do not need the \bin at the end.
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args)
{
CommandArgumentCollection argumentCollection = new CommandArgumentCollection(args);
if (argumentCollection.GetFirstArgument("console") != null)
@taylorc
taylorc / ServiceTest.cs
Created May 12, 2013 11:40
Custom AppenderSkeleton
public class CustomMemoryAppender : AppenderSkeleton
{
private readonly StringBuilder logBuffer;
readonly StringWriter stringWriter;
private readonly object lockObject = new object();
public CustomMemoryAppender()
{
logBuffer = new StringBuilder();
stringWriter = new StringWriter(logBuffer);