Skip to content

Instantly share code, notes, and snippets.

View cbanner's full-sized avatar

Christopher Banner cbanner

View GitHub Profile
@cbanner
cbanner / IAuthenticationStep.cs
Created December 29, 2018 17:58
Part 3: Pseudo code demonstrating the final phase of how to isolate logging components through decoration.
public interface IAuthenticationStep
{
bool IsAuthentic(HttpRequest request);
}
@cbanner
cbanner / LoggingAuthenticationProcedure.cs
Last active December 29, 2018 13:57
Part 2: Pseudo code demonstrating how to isolate logging components through decoration.
public class LoggingAuthenticationProcedure : IAuthenticationProcedure
{
private readonly ILogger logger;
private readonly IAuthenticationProcedure innerProcedure;
public LoggingAuthenticationProcedure(ILogger logger, IAuthenticationProcedure procedure)
{
this.logger = logger;
this.innerProcedure = procedure;
}
@cbanner
cbanner / SignatureAuthenticationProcedure.cs
Last active December 28, 2018 21:45
Part 1: Pseudo code demonstrating the pervasiveness of logging components when allowed to infiltrate classes.
public class SignatureAuthenticationProcedure : IAuthenticationProcedure
{
private readonly ILogger logger;
public SignatureAuthenticationProcedure(ILogger logger)
{
this.logger = logger;
}
public AuthenticationResult Authenticate(HttpRequest request)
@cbanner
cbanner / HttpRequestExtensions.cs
Created November 21, 2017 21:06
An extension method to ASP.NET Core's HttpRequest class, delivering the original request target
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
/// <summary>
/// Gets the raw target of an HTTP request.
/// </summary>
/// <returns>Raw target of an HTTP request</returns>
/// <remarks>
/// ASP.NET Core manipulates the HTTP request parameters exposed to pipeline
/// components via the HttpRequest class. This extension method delivers an untainted
@cbanner
cbanner / MyPageController.cs
Last active May 18, 2017 13:34
This Gist is a companion to a post on the Episerver Social blog called "Getting Started with Comments": http://world.episerver.com/blogs/chris-banner/dates/2017/5/getting-started-with-comments/. It demonstrates the fundamentals of working with Comments in Episerver Social.
public class MyPageController : ContentController<MyContent>
{
private readonly ICommentService commentService;
public MyPageController()
{
commentService = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<ICommentService>();
}
// ...