Skip to content

Instantly share code, notes, and snippets.

@mikaelo
mikaelo / AsyncMediatorPipeline.cs
Last active August 29, 2015 14:26
AsyncMediatorPipeline and Autofac Registration
public class AsyncMediatorPipeline<TRequest, TResponse> : IAsyncRequestHandler<TRequest, TResponse> where TRequest : IAsyncRequest<TResponse>
{
private readonly IAsyncRequestHandler<TRequest, TResponse> inner;
private readonly IAsyncPreRequestHandler<TRequest>[] preRequestHandlers;
private readonly IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers;
public AsyncMediatorPipeline(IAsyncRequestHandler<TRequest, TResponse> inner, IAsyncPreRequestHandler<TRequest>[] preRequestHandlers, IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers)
{
this.inner = inner;
using System.Collections.Generic;
namespace System.Threading
{
public class PollingWorker : IPollingWorker,IDisposable
{
private class TickAction
{
public string Name { get; set; }
public Action Work { get; set; }
using System.Collections.Generic;
namespace System.Threading
{
public class PollingWorker : IPollingWorker,IDisposable
{
private class TickAction
{
public string Name { get; set; }
public Action Work { get; set; }
// ProxyRequest proxies a request to a JSON-based API
// to avoid the cross origin request issue.
// It assumes the API supports POST.
// JsonResult is an ASP.NET MVC construct.
private JsonResult ProxyRequest(string url, string data)
{
HttpWebRequest wr = (HttpWebRequest)HttpWebRequest.Create(url);
wr.Method = "POST";
wr.ContentType = "application/json";
@mikaelo
mikaelo / gist:5021510
Created February 23, 2013 21:51 — forked from hydr/gist:4338698
public static List<List<Coordinate>> ToGoogleMapsPolygon(this DbGeography dbGeo)
{
// contains all geo data for one postal code / admin area code
// conversion to SqlGeography because DbGeography does not offer properties to determine rings within geometries. we need those ring information to display areas with holes
var sqlGeo = (SqlGeography) dbGeo.ProviderValue;
var numberOfGeometries = sqlGeo.STNumGeometries();
var result = new List<List<Coordinate>>((int) numberOfGeometries);
ko.bindingHandlers.modal = {
update: function (element, valueAccessor) {
$(element).click(function () {
$.fancybox({ content: $('<div/>').addClass('list-widget').html($('.content', $(element).parent()).html()) });
});
}
};
@mikaelo
mikaelo / ScriptExtensions.cs
Created December 4, 2012 07:50 — forked from johnnyreilly/ScriptExtensions.cs
HTML Helper for creating / rendering scripts when working in ASP.NET MVC (heavily based on Michael Ryans original work; see links enclosed)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
using System.Text;
namespace DummyMvc.Helpers
{