Skip to content

Instantly share code, notes, and snippets.

@shanefulmer
Created August 13, 2012 01:23
Show Gist options
  • Save shanefulmer/3336201 to your computer and use it in GitHub Desktop.
Save shanefulmer/3336201 to your computer and use it in GitHub Desktop.
Handler 5
public class CoreRegistry : Registry
{
public CoreRegistry()
{
Scan(cfg =>
{
cfg.TheCallingAssembly();
cfg.WithDefaultConventions();
cfg.IncludeNamespaceContainingType<Foo>();
cfg.ConnectImplementationsToTypesClosing(typeof(IRenderer<>));
});
}
}
class Program
{
static void Main(string[] args)
{
ObjectFactory.Initialize(init => init.AddRegistry<CoreRegistry>());
var fooRenderers = ObjectFactory.GetAllInstances<IRenderer<Foo>>();
var textHandler = fooRenderers.SingleOrDefault(x => x.GetType().Name.Contains("Text"));
textHandler.Render(new Foo());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment