I know that I can pass a value to single instance:
container.Register(() => new Service(value));
But I want to register a collection of instances using collection of assemblies, like this:
container.RegisterCollection<IService>(assemblies);
All instances have equal constructor signature. How do I pass a value to all constructors?
Update
Due to Steven's comment i should clarify that a value i want to pass is CancellationToken
.
It isn't a good idea to depend on primitive values. A service should depend on abstractions. Create a new interface describing the service that supplies the necessary value and have the instances depend on that. If different instances need different values, they should depend on separate interfaces to supply the values. This answer gives more details and has an example of how to achieve what you're trying to do.