Skip to content

Instantly share code, notes, and snippets.

public class User { }
public class Order { }
public interface ILoader<out T>
{
IEnumerable<T> Load();
}
public class UserLoader : ILoader<User>
{
public interface ILoader<out T>{
IEnumerable<T> Load();
}
public class User {}
public class UserLoader : ILoader<User>
{
public IEnumerable<User> Load()
{
//return Loaded users
}
}
var container = new WindsorContainer();
container.Register(Classes.FromThisAssembly()
.BasedOn(typeof (ILoader<>))
.WithService
.Select(new []{typeof(ILoader<object>)}));
covariantArray = container.ResolveAll<ILoader<object>>();
var container = new WindsorContainer();
container.Register(Component.For<ILoader<object>>().ImplementedBy<UserLoader>());
covariantArray = container.ResolveAll<ILoader<object>>();
public class SimpleInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
invocation.Proceed();
}
}
Windsor.InitialiseCore();
Windsor.Container.Register(Component.For<IInterceptor>()
.ImplementedBy<SimpleInterceptor>());
[Interceptor(typeof(SimpleInterceptor))]
public class TestClass
{
public virtual void DoStuff()
{
//Do Important Stuff
}
}
@tjchaplin
tjchaplin / GruntInstall
Created June 29, 2013 07:25
Getting Started With Grunt
//install grunt command line interface(CLI)
npm install -g grunt-cli
//install grunt into the projects modules
npm install grunt --save-dev
//install JSHint package
npm install grunt-contrib-jshint --save-dev
//install Watch configuration
@tjchaplin
tjchaplin / sampleGruntConfiguration.js
Created June 29, 2013 07:40
A sample grunt configuration
module.exports = function(grunt) {
// configuration.
grunt.initConfig({
//Package file
pkg: grunt.file.readJSON("package.json"),
//jshint - configuration
jshint: {
files: ["gruntfile.js", "index.js", "lib/**/*.js","test/**/*.js"],
options: {