Is it possible for one component to have a lifestyle "like some other component" or "following some other component"? Meaning that ClassA gets a ClassB in its constructor, and should stay the same instance until ClassB is trashed.
If ClassB is a singleton, ClassA should also behave like a singleton. If ClassB is PerWebRequest, every ClassA within the same request will have the same ClassB instance (and, the more important part; be the same ClassA instance). In short: ClassA should resolve to the same instance as long as ClassB resolves to the same instance. The idea behind this is to have a graph where a configuration class appears at some point (which has a custom lifestyle that causes it to be trashed when the configuration file changes); and the instances in this graph behave like singletons until the configuration does actually change. At first glance, i thought Lifestyle.BoundTo<ConfigurationClass>() might do, but it seems to work the other way round (dependency follows parent, not parent follows dependency); and something like Lifestyle.Follows<ConfigurationClass>() would be needed. So, would something like this be possible, or is there even a facility for that? And, of course: Should I even think of doing something like this, or is it totally the wrong way to go? In the real application, a lightweight facade (PerWcfOperation; or Transient if you like) gets a repository-style class which does some heavy lifting on first access and caches it for subsequent access (this one could use the new lifestyle; it would be a singleton if the configuration file were static). Parameters on where the repository gets its stuff from is loaded from the config file (using the nifty trick from http://mikehadlow.blogspot.co.at/2010/02/10-advanced-windsor-tricks-9.html; which would have the custom lifestyle of UntilConfigurationFileIsChanged or whatever it would be called later). - BhaaL -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/xOsUGpXHWJkJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
