Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'StructureMap.ObjectFactory' is obsolete

I implemented a interface injection using StructureMap as describe below.

ObjectFactory.Initialize(x => { x.For<*IRepository*>().Use<*SQLRepository*>(); });

But it is giving a warning as follows

Warning 2 'StructureMap.ObjectFactory' is obsolete: 'ObjectFactory will be removed in a future 4.0 release of StructureMap. Favor the usage of the Container class for future work'.

How do I correct this by using Container class

like image 394
abn Avatar asked Dec 24 '22 18:12

abn


1 Answers

You can create an instance of a container directly, per their documentation. The syntax is relatively similar.

var container = new Container(x =>
{
    x.ForRequestedType<IRepository>().Use<SQLRepository>();
});
like image 127
David L Avatar answered Dec 31 '22 14:12

David L