Skip to content

Instantly share code, notes, and snippets.

namespace Core
{
public interface IResolver
{
T Resolve<T>();
}
}
@bitsprint
bitsprint / ServiceLocator.cs
Created June 7, 2013 08:35
Windsor Service Locator
namespace Core
{
using Castle.Windsor;
public static class ServiceLocator
{
public static IWindsorContainer Container { get; set; }
}
}
@bitsprint
bitsprint / DomainToViewModel.cs
Created June 7, 2013 08:32
AutoMapper Domain To ViewModel Profile
namespace Web.Profiles.DomainToViewModel
{
using System.Linq;
using System.Reflection;
using AutoMapper;
using Core.Extensions;
public partial class DomainToViewModel : Profile
[Test]
public void ActionReturnsRedirectToRouteResult()
{
var result = this.controller.Action();
Assert.That(result, Is.TypeOf<RedirectToRouteResult>());
var routeResult = (RedirectToRouteResult)result;
Assert.That(routeResult.RouteValues["area"], Is.EqualTo(string.Empty));
@bitsprint
bitsprint / ControllerHelper.cs
Created June 6, 2013 12:05
ControllerHelper
namespace Web.Tests.TestHelpers
{
using System;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
@bitsprint
bitsprint / consoleLogger.js
Created May 24, 2013 09:54
Console Logger
var App = App || { };
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'App'
], factory);
@bitsprint
bitsprint / logger.js
Created May 23, 2013 08:33
Base Logger
var App = App || {};
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
App
], factory);
} else {
@bitsprint
bitsprint / UiExtensions.js
Created May 23, 2013 07:49
jQuery UI DateTime extensions
var App = { namespace: 'foo' };
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery'
, 'jqueryui'
, App
@bitsprint
bitsprint / date.js
Created May 22, 2013 15:47
Date functions
Date.prototype.formatDDMMYYYY = function () {
return ('0' + this.getDate()).slice(-2) +
'/' + ('0' + (this.getMonth() + 1)).slice(-2) +
'/' + this.getFullYear();
};
Date.prototype.formatDDMMYYYYWithHMS = function () {
return ('0' + this.getDate()).slice(-2) +
'/' + ('0' + (this.getMonth() + 1)).slice(-2) +
'/' + this.getFullYear() +
@bitsprint
bitsprint / number.js
Created May 22, 2013 15:43
Number functions
Number.prototype.formatMoney = function (c, d, t) {
var n = this,
s = n < 0 ? "-" : "",
j = (j = i.length) > 3 ? j % 3 : 0;
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d === undefined ? "," : d,
t = t === undefined ? "." : t,
var i = parseInt(n = Math.abs(+n || 0).toFixed(c), 10) + "";