Project Description
A compact IoC container built specifically for XNA. It has most the features you would expect from a container, life cycle management, singletons, prototypes, auto-wiring, late injection, look up by interface or name and more in about 500 lines of code.
Reflection is minimal so that it is usable in XNA and with the Compact Framework. Also, configuration is code only with no XML in sight. See below for a quick example, there is complete example project that shows most of the features in the repository, see here.

container = new RadialityContainer();

container.Bind<GameConsole>("Console").To(delegate(RadialityContainer r) {
    Game1 game1 = r.Get<Game1>();
    GameConsole console = new GameConsole(game1);
    game1.Components.Add(console);
    return console;
   });

r.Bind<SpriteFont>("ConsoleFont").To(delegate {
     Game1 game1 = r.Get<Game1>();
     return game1.Content.Load<SpriteFont>("Fonts/LiberationMono12");
    }).InjectNow();

r.Bind<Texture2D>("ConsoleBackgroundTexture").To(delegate {
     Game1 game1 = r.Get<Game1>();
     return game1.Content.Load<Texture2D>("Textures/ConsoleBackground");
    }).InjectNow();

container.Bind<Gameplay>().To(delegate(RadialityContainer r) {
    Game1 game1 = r.Get<Game1>();
    Gameplay gameplay = new Gameplay(game1, null, r);
    return gameplay;
   });


Thanks for playing,
Ark @ http://arkarua.blogspot.com/

Last edited Feb 12, 2009 at 7:02 PM by arkarua, version 4