Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created January 8, 2010 14:59
Show Gist options
  • Save jfromaniello/272091 to your computer and use it in GitHub Desktop.
Save jfromaniello/272091 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.Resolvers;
namespace CompositeWPFContrib.Composite.WindsorExtensions
{
public class LazyLoader : ILazyComponentLoader
{
private readonly string[] allowedAssembliesNames = new[]
{
"Microsoft.Practices.Composite",
"Microsoft.Practices.Composite.Presentation",
"Microsoft.Practices.Composite.Wpf"
};
#region ILazyComponentLoader Members
public IRegistration Load(string key, Type service)
{
if (allowedAssembliesNames.Any(n => service.Assembly.FullName.StartsWith(n)))
{
return Component.For(service).Named(key).LifeStyle.Transient;
}
return null;
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment