// registry is a StructureMap Registry object
registry.For<IService>().AddInstances(x =>
{
// Equivalent to For<IService>().Add<ColorService>().....
x.Type<ColorService>().Named("Red").Ctor<string>("color").Is("Red");
// Equivalent to For<IService>().Add(new ColorService("Yellow"))......
x.Object(new ColorService("Yellow")).Named("Yellow");
// Equivalent to For<IService>().Use(() => new ColorService("Purple"))....
x.ConstructedBy(() => new ColorService("Purple")).Named("Purple");
x.Type<ColorService>().Named("Decorated").Ctor<string>("color").Is("Orange");
});
However, AddInstances() does not exist, I get the following error
'ServiceRegistry.InstanceExpression' does not contain a definition for 'AddInstances' and no accessible extension method 'AddInstances' accepting a first argument of type 'ServiceRegistry.InstanceExpression' could be found (are you missing a using directive or an assembly reference?)
Is this in another namespace? does it only exist on a StructureMap Registry object as per the example, if so how do I get that from the injected ServiceRegistry?
I have a dotnet core website setup with Lamar, I have the following method in Startup.cs
I want to use AddInstances() as described in the documents at https://jasperfx.github.io/lamar/documentation/ioc/registration/registry-dsl/
Add Many Registrations with For().AddInstances()
However, AddInstances() does not exist, I get the following error
Is this in another namespace? does it only exist on a StructureMap Registry object as per the example, if so how do I get that from the injected ServiceRegistry?
Any help is appreciated :)
I have also asked this question on stackoverflow https://stackoverflow.com/questions/59324724/lamar-addinstances-with-serviceregistry