3

I'm looking into TinyIOC for ASP.NET MVC application.

What I'm trying to do is register some interface as singleton per request using factory method.

var container = TinyIoC.TinyIoCContainer.Current;
container.Register<IGlobal>((c, n) => FactoryMethod()).AsPerRequestSingleton();

The code above gives me Cannot convert current registration of TinyIoC.TinyIoCContainer+DelegateFactory to singleton. Is there a way to implement this with TinyIOC without using ChildContainers?

Shaddix
  • 5,901
  • 8
  • 45
  • 86

1 Answers1

4

Sorry, forgot that....

So, TinyIoC currently (as of 1.2) can't register for singleton lifestyles when using factory methods.

Oh, and as you mention child containers - be careful with those, they're broken as well.

TeaDrivenDev
  • 6,591
  • 33
  • 50
  • A link to the issue? – Deilan Oct 28 '16 at 14:40
  • I don't know if one exists. I never bothered to file TinyIoC issues, because at the time, the project appeared all but dead, and issues and pull requests were piling up without even a response. – TeaDrivenDev Oct 28 '16 at 15:45