I have numerous (60 or 70) classes that subclass a shared base class. This base class exposes a property of type ICacheProvider
that needs to be set when each of the superclasses is registered with structuremap. I am using structuremap version 2.6.1. Currently, I am setting the property for each superclass, thus:
For<IBusinessRule<IEnumerable<int>>>()
.Use<ManufacturersWithReviewsRule>()
.Named(NamedRuleConstants.ManufacturersWithReviews)
.Setter<ICacheProvider>().Is(ObjectFactory.GetNamedInstance<ICacheProvider>(CacheConstants.IndexCacheKeyPrefix));
For<IBusinessRule<IEnumerable<int>>>()
.Use<ManufacturersWithOwnersReviewsRule>()
.Named(NamedRuleConstants.ManufacturersWithOwnersReviews)
.Setter<ICacheProvider>().Is(ObjectFactory.GetNamedInstance<ICacheProvider>(CacheConstants.IndexCacheKeyPrefix));
For<IBusinessRule<IEnumerable<int>>>()
.Use<ManufacturersWithLivingWithItRule>()
.Named(NamedRuleConstants.ManufacturersWithLivingWithIt)
.Setter<ICacheProvider>().Is(ObjectFactory.GetNamedInstance<ICacheProvider>(CacheConstants.IndexCacheKeyPrefix));
(ManufacturersWithReviewsRule, ManufacturersWithOwnersReviewsRule, ManufacturersWithLivingWithItRule each subclass BaseBusinessRule)
What I want to do is specify the:
.Setter<ICacheProvider>().Is(ObjectFactory.GetNamedInstance<ICacheProvider>(CacheConstants.IndexCacheKeyPrefix));
a single time for all, allowing me to set it individually where necessary should I require a different ICacheProvider.
Is this possible using structuremap 2.6.1? I can find no way of doing it.