'StructureMap.ObjectFactory' is obsolete
Asked Answered
P

1

5

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

Proletariat answered 9/6, 2015 at 4:39 Comment(2)
#25551414 ?Akkerman
dennisrongo.com/…Hoxie
R
11

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>();
});
Rhinology answered 9/6, 2015 at 4:43 Comment(1)
Your documentation link is 404 not foundCentrosome

© 2022 - 2024 — McMap. All rights reserved.