Skip to content

Instantly share code, notes, and snippets.

View marcofranssen's full-sized avatar
🏠
Diving into code

Marco Franssen marcofranssen

🏠
Diving into code
View GitHub Profile
@marcofranssen
marcofranssen / gist:1034436
Created June 19, 2011 16:09
MergingHandler Example
public class MergingHandler<T> : Consumes<T>
{
public MergingHandler(Consumes<T> next)
{
}
public void Consume(T message)
{
try
{
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Castle.Windsor;
using Castle.Windsor.Installer;
using Website.Infrastructure;
@marcofranssen
marcofranssen / BisAggregateRoot.cs
Created August 4, 2011 09:01
Event tracking for your aggregates to prepare your eventstore
public abstract class BisAggregateRoot : AggregateRootMappedByConvention
{
private readonly List<object> _appliedEvents = new List<object>();
protected readonly ICredentials Credentials = NcqrsEnvironment.Get<ICredentials>();
protected BisAggregateRoot()
{
}
@marcofranssen
marcofranssen / ActualTest.cs
Created August 10, 2011 17:56
Gists related to my "Pitfall in FakeItEasy" blogpost on http://marcofranssen.nl
[Then]
public void it_should_throw_an_formatted_participant_nr_should_be_unique_exception_containing_the_formatted_participant_nr()
{
var exception = (FormattedParticipantNrShouldBeUniqueException)CaughtException;
exception.FormattedParticipantNr.Should().Be(_formattedParticipantNr);
}
@marcofranssen
marcofranssen / ControllerActionExample.cs
Created September 13, 2011 17:46
Gists related to my "Knockout that cascading dropdown" blogpost on http://marcofranssen.nl
public JsonResult States(string country)
{
var states = _countryRepository.GetStates(country)
.Select(s => new {
text = s.StateName,
value = c.StateCode
});
return new JsonResult { Data = states, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
@marcofranssen
marcofranssen / productDialog.js
Created September 17, 2011 16:16
Gist related to my "jQuery events contributes to clean Javascript" blogpost on http://marcofranssen.nl
var productDialog = function($){
var self = null;
var dialogForm = null;
var init = function() {
if (self === null) return;
self = this;
initDialog();
};
@marcofranssen
marcofranssen / SafeCommandService.cs
Created November 19, 2011 17:31
Gist realted to my "Auto retry concurrent commands with ncqrs" blogpost on http://marcofranssen.nl
public class SafeCommandService : CommandService
{
public override void Execute(ICommand command)
{
try
{
base.Execute(command);
}
catch(ConcurrencyException ex)
{
@marcofranssen
marcofranssen / _jsShop.product.js
Created January 23, 2012 18:48
Gist related to my "Writing modular JavaScript without polluting the global namespace" blogpost on http://marcofranssen.nl
; (function(jsShop, window, document, undefined) {
var product = jsShop.product = jsShop.product || (function() {
//an implementation like shoppingCart
}());
}(window._jsShop = window._jsShop || {}, window, document));
@marcofranssen
marcofranssen / CompareExtensions.cs
Last active October 2, 2015 07:18
Gist related to my "Delegate your equality comparisons" blogpost on http://marcofranssen.nl
public static class CompareExtensions
{
public static IEnumerable<T> Distinct<T>(this IEnumerable<T> items, Func<T, T, bool> equals, Func<T, int> hashCode)
{
return items.Distinct(new DelegateEqualityComparer<T>(equals, hashCode));
}
public static IEnumerable<T> Distinct<T>(this IEnumerable<T> items, Func<T, T, bool> equals)
{
return items.Distinct(new DelegateEqualityComparer<T>(equals, null));
@marcofranssen
marcofranssen / CategoryController.cs
Last active October 5, 2015 00:57
Gist related to my "Secure your web app fluently" at http://marcofranssen.nl
public class CategoryController
{
[HttpGet]
public ActionResult AddNewCategory()
{
return View(new CategoryModel());
}
[HttpPost]
public ActionResult AddNewCategory(CategoryModel model)