using System.Collections.Generic;
using System.Reactive.Linq;
Tuple<IBox<ICat>, ICat, IBox<IBox<ICat>>> tuple,
IEnumerable<IBox<ICat>> enumerable,
IObservable<IBox<ICat>> observable,
IBox<Lazy<Func<IEnumerable<IBox<ICat>>>>> complex)
Console.WriteLine(bigBox);
Console.WriteLine("{0} from func", func());
Console.WriteLine("Tuple of {0}", tuple);
Console.WriteLine("Lazy of {0}", lazy.Value);
Console.WriteLine("Enumeration of {0}", enumerable.Single());
Console.WriteLine("Array of {0}", array.Single());
Console.WriteLine("List of {0}", list.Single());
Console.WriteLine("Set of {0}", set.Single());
Console.WriteLine("Observable of {0}", observable.Single());
Console.WriteLine("Complex {0}", complex.Content.Value().Single());
public static void Main()
using (new Glue().BuildUp<Program>()) { }
interface IBox<out T> { T Content { get; } }
interface ICat { State State { get; } }
enum State { Alive, Dead }
class CardboardBox<T> : IBox<T>
public CardboardBox(T content) { Content = content; }
public T Content { get; private set; }
public override string ToString() { return "[" + Content + "]"; }
class ShroedingersCat : ICat
private readonly Lazy<State> _superposition;
public ShroedingersCat(Lazy<State> superposition) { _superposition = superposition; }
public State State { get { return _superposition.Value; } }
public override string ToString() { return State + " cat"; }
class Glue : IConfiguration
public IEnumerable<IToken> Apply(IContainer container)
.Bind<IBox<TT>>().To<CardboardBox<TT>>()
.Bind<ICat>().To<ShroedingersCat>();
var indeterminacy = new Random();
yield return container.Bind<State>().To(ctx => (State)indeterminacy.Next(2));