i am trying to understand if i need to use .singleton() in my structure map code. there is already a question about this on stackoverflow (StructureMap singleton) but i want to be sure i'm definitely using the correct syntax. One of the answers implies that if i am returning a type i need to use .singleton() so that my code here:
x.For<IApprovedProgrammesHelper>().Use<ApprovedProgrammesHelper>();
x.For(typeof(ICache<>))
.Use(typeof(CacheHelper<>))
.Dependencies.Add(typeof(TimeSpan), Settings.Instance.HttpCacheExpiration);
should look like this:
x.For<IApprovedProgrammesHelper>().singleton().Use<ApprovedProgrammesHelper>();
x.For(typeof(ICache<>))
.Singleton()
.Use(typeof(CacheHelper<>))
.Dependencies.Add(typeof(TimeSpan), Settings.Instance.HttpCacheExpiration);
is this correct? Or have i misunderstood how this should work? I'm not completely sure what the implications are for the code either way. It's probably worth mentioning that the types in the .Use<> statement do not follow the singleton pattern anyway.
Thanks for your time in advance Sam