Hello,
I've been thinking of some helper component that could save little
keystrokes. And instead of writing this:
IMyFactory Factory { get; set; }
void foo()
{
ISilverOblogon oblogon = Factory.CreateSilverOblogon();
try
{
// use oblogon
}
finally
{
Factory.Release(oblogon);
}
}
One could do
FactoryScope<IMyFactory, ISilverOblogon> OblogonFactory { get; set; }
// FactoryScope has Factory inside injected by container
void bar()
{
using (var wrapper = OblogonFactory.AcquireObject())
// FactoryScope finds and calls CreateSilverOblogon method
{
// use wrapper.Object which is ISilverOblogon
} // wrapper.Dispose calls Factory.Release method
}
Is there anything like this around? Does it make any sense at all?
--
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/-/mGweFc_e_JQJ.
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.