3

My StructureMap configuration looks like this:

container.Configure(x => x.For<IStreamWrap>().Use<FileStreamWrap>().SelectConstructor(() => new FileStreamWrap("", System.IO.FileMode.Open));

I'm trying to get an instance of FileStreamWrap and passing in two arguments:

stream = container.With("path").EqualTo(path).With("mode").EqualTo(System.IO.FileMode.Open).GetInstance<IStreamWrap>();

But I get an exception with this message and I don't know why StructureMap still chooses the constructor with the most arguments as I explicitly told it to use the constructor with two arguments (FileStreamWrap(string path, System.IO.FileMode mode))

Unable to create a build plan for concrete type SystemWrapper.IO.FileStreamWrap

new FileStreamWrap(String path, FileMode mode, FileSystemRights rights, FileShare share, Int32 bufferSize, FileOptions options, FileSecurity)
  ┣ String path = Value: path
  ┣ FileMode mode = Value: Open
  ┣ FileSystemRights rights = Required primitive dependency is not explicitly defined
  ┣ FileShare share = Required primitive dependency is not explicitly defined
  ┣ Int32 bufferSize = Required primitive dependency is not explicitly defined
  ┣ FileOptions options = Required primitive dependency is not explicitly defined
  ┗ FileSecurity = **Default**

Any advice would be greatly appreciated.

cortex42
  • 234
  • 1
  • 13

0 Answers0