Skip to content

Instantly share code, notes, and snippets.

@cammerman
Created February 10, 2011 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cammerman/819967 to your computer and use it in GitHub Desktop.
Save cammerman/819967 to your computer and use it in GitHub Desktop.
Cache registrations
builder
.RegisterType<Cache>()
.Keyed<ECacheType>(ECacheType.Thumb)
.As<ICache>()
.InstancePerLifetimeScope();
builder
.RegisterType<Cache>()
.Keyed<ECacheType>(ECacheType.Image)
.As<ICache>()
.InstancePerLifetimeScope();
public class ImageBrowser
{
public virtual ICache ThumbCache
{
get;
private set;
}
public virtual ICache ImageCache
{
get;
private set;
}
public ImageBrowser(ICache thumbCache, ICache imageCache)
{
ThumbCache = thumbCache;
ImageCache = imageCache;
}
}
protected virtual void OnPreparingImageBrowser(PreparingEventArgs e)
{
e.Parameters = new[] {
new NamedParameter(
"thumbCache",
e.Context
.ResolveKeyed<ICache>(ECacheType.Thumb)),
new NamedParameter(
"imageCache",
e.Context
.ResolveKeyed<ICache>(ECacheType.Image))
};
}
builder
.RegisterType<ImageBrowser>()
.OnPreparing(OnPreparingImageBrowser)
.AsSelf()
.InstancePerLifetimeScope();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment