dependency injection - Castle.Windsor - understanding transient lifestyle -
new castle.windsor , wanted check something.
i've been reading transient lifestyles , "releasing resolve" - i've created resource provider asp.net mvc3 application , resolving within new resource provider factory (which "hub" resource access in asp.net):
icontaineraccessor accessor = httpcontext.current.applicationinstance icontaineraccessor; iresourceprovider provider = accessor.container.resolve<iresourceprovider>(new arguments(new { resourcename = resourcename })); loggerservice.information(string.format("tracking? {0}", accessor.container.kernel.releasepolicy.hastrack(provider))); the iresourceprovider transient can pass different resourcename constructor (so different labels can returned different resource files).
i concerned i'd need explicitly call release on these iresourceprovider objects hastrack check returns false - assume thing?
the container isn't tracking object gc (eventually clean object up).
when container track object - if had creation commission concerns?
you release components explicity ask for. there 2 ways of explicitly obtaining component:
a) resolve, used above. in general practise have single resolve call in application. want typedfactoryfacility.
b) use of factory. in case use typefactoryfacility. if obtain component factory , it's dependencies released when:
- you release explicitly calling "destroy" method on factory.
- or factory self released.
if didn't create component explicitly should never have release it.
Comments
Post a Comment