This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
namespace YourWebsite.Filters | |
{ | |
public class ObjectNotFoundExceptionFilterAttribute : ActionFilterAttribute, IExceptionFilter | |
{ | |
public void OnException(ExceptionContext filterContext) | |
{ | |
if (filterContext.Exception is NHibernate.ObjectNotFoundException) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Text; | |
using Newtonsoft.Json.Schema; | |
namespace JsonSchemaToCode | |
{ | |
public class CSharpObjectDefinition : ObjectDefinition | |
{ | |
public override string ToString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Program"> | |
<NuGetReference>Newtonsoft.Json</NuGetReference> | |
<NuGetReference>Rx-Main</NuGetReference> | |
<NuGetReference>StackExchange.Redis</NuGetReference> | |
<Namespace>System.Reactive.Linq</Namespace> | |
<Namespace>System.Reactive.Disposables</Namespace> | |
<Namespace>StackExchange.Redis</Namespace> | |
</Query> | |
void Main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Program"> | |
<Reference><RuntimeDirectory>\System.Net.Http.dll</Reference> | |
<NuGetReference>Microsoft.AspNet.WebApi.OwinSelfHost</NuGetReference> | |
<Namespace>Microsoft.Owin.Hosting</Namespace> | |
<Namespace>Owin</Namespace> | |
<Namespace>System.Web.Http</Namespace> | |
<Namespace>System.Net.Http</Namespace> | |
<Namespace>System.Net</Namespace> | |
</Query> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using log4net.Appender; | |
using log4net.Core; | |
using log4net.Layout; | |
namespace RestTest.Logging | |
{ | |
public static class Log4NetAppenderFactory | |
{ | |
private static readonly PatternLayout PatternLayout = new PatternLayout("[%-5level][%date][%thread][%logger]: %message%newline"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.IdentityModel.Tokens; | |
using System.Web.Mvc; | |
using System.Web.Optimization; | |
using System.Web.Routing; | |
using Microsoft.Owin; | |
using Microsoft.Owin.Security.Cookies; | |
using Microsoft.Owin.Security.OpenIdConnect; | |
using OauthScratch.MvcOwinClient; | |
using Owin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Microsoft.Owin; | |
using Owin; | |
using OwinSpike.Simple.Console; | |
//Console app | |
//NuGet packages : | |
//<package id="Microsoft.Owin.SelfHost" version="3.0.0" targetFramework="net45" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RequireApiKey : ActionFilterAttribute | |
{ | |
private static readonly ILog Logger = LogManager.GetLogger(typeof(RequireApiKey)); | |
public override void OnActionExecuting(HttpActionContext context) | |
{ | |
var ipAddress = GetIpAddress(context); | |
Logger.InfoFormat("API attempt. Uri {0} - IP {1} - Headers {2} ", context.Request.RequestUri, ipAddress, context.Request.Headers); | |
IEnumerable<string> values; | |
if (context.Request.Headers.TryGetValues("ApiKey", out values) && GetApiKeys().Any (x => x ==values.First()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using Xunit; | |
namespace MyNameSpace.Tests | |
{ | |
public class CacheTests | |
{ | |
[Fact] | |
public void CanReuseCachedObject() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CmsController : BootstrapBaseController | |
{ | |
private readonly PrismicProxy _prismicProxy; | |
public CmsController(PrismicProxy prismicProxy) | |
{ | |
_prismicProxy = prismicProxy; | |
} | |
public ActionResult Dynamic(string id) |