Skip to content

Instantly share code, notes, and snippets.

View dealproc's full-sized avatar

Richard Bennett dealproc

View GitHub Profile
@dealproc
dealproc / WorkerRole.cs
Created January 7, 2016 09:49
Azure Worker Role for hosting an Owin application
namespace Your.Product.Namespace
{
public class WorkerRole : RoleEntryPoint, IDisposable
{
readonly TaskCompletionSource<bool> _endRole = new TaskCompletionSource<bool>();
readonly ManualResetEvent _runCompleteEvent = new ManualResetEvent(false);
IDisposable _app;
bool _disposed = false;
~WorkerRole()
@dealproc
dealproc / map.cshtml
Created January 11, 2016 14:56
_paws map.cshtml
<style type="text/css">
#legend {
background-color: #3C5A76;
border: 2px solid #cccc;
color: #EEEEEE;
font-weight: bold;
position: absolute;
right: 50px;
top: 50px;
padding: 15px;
@dealproc
dealproc / TaskExtensions.cs
Last active January 12, 2016 19:07
Retry logic for tasks
namespace YourProduct
{
/// <summary>
/// Task retry logic
/// </summary>
public static class TaskHelper
{
/// <summary>
/// Returns a task which retries the task returned by the specified task provider.
/// </summary>
@dealproc
dealproc / TestServerFixture.cs
Created January 25, 2016 20:08
Sample Fixture for an owin test server
using Microsoft.Owin.Testing;
using System;
using System.Linq;
using System.Net.Http;
using Xunit;
namespace {Your Project}.Tests.Fixtures {
[CollectionDefinition("Test Server")]
@dealproc
dealproc / ApiTestBase.cs
Created February 12, 2016 13:53
base test class for nancy
using FakeItEasy;
using Nancy.Owin;
using Nancy.Testing;
using Nancy.TinyIoc;
using Owin;
using System;
using System.Collections.Generic;
@dealproc
dealproc / program.cs
Created April 11, 2016 18:25
Keyed instances of object(s)
using System;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Autofac;
namespace AFMetadata {
class Program {
@dealproc
dealproc / ICache.cs
Last active August 31, 2016 22:58
Caching (in-memory and redis)
using System;
namespace {yourapp}.Infrastructure.Caching {
public interface ICache {
/// <summary>
/// Determines whether the specified keyformat contains key.
/// </summary>
/// <param name="keyformat">The keyformat.</param>
/// <param name="arguments">The arguments.</param>
/// <returns></returns>
/// <summary>
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
/// <param name="loggerFactory"></param>
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
@dealproc
dealproc / IBrokeredRequest.cs
Created April 7, 2018 16:29
CQS with MediatR
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
public interface INotificationWithIdentification : INotification
{
Guid RequestID { get; set; }
{
"version": "0.2.0",
"configurations": [
{
"name": "{your project}",
"type": "coreclr",
"request": "launch",
"cwd": "/app",
"program": "/app/{your project dll}.dll",
"sourceFileMap": {