I'm new to structureMap. How do I define constructor arguments for the following class with fluent configuration? Thanks
  public BlobContainer(CloudStorageAccount account
              , string containerName
              , string contentType
              , BlobContainerPermissions blobContainerPermissions)
  {
  }
                For primitive types you would go about as @ozczecho answered:
For<BlobContainer>()
  .Use<BlobContainer>()
  .Ctor<string>("containerName").Is("theContainerName")
  .Ctor<string>("contentType").Is("theContentType");
provided that the values are known at registration time. You can do it this way for non-primitive types as well, but you lose the flexibility that the container gives you this way. It's better to define a default or named instance and use that instead (the container will automatically resolve default instances for you). By defining defaults you can easily change all the dependencies on a type in your application by changing just one registation.
For<CloudStorageAccount>().Use<TheCloudStorageAccountType>();
If a dependency is a concrete type with a constructor having dependencies that are known to structuremap you don't have to register it with the container, it will be automatically resolved.
So if CloudStorageAccount is a concrete class you only need to register it's dependencies in Structure Map.
        For<BlobContainer>()
            .HybridHttpOrThreadLocalScoped()
            .Use<BlobContainer>()
            .Ctor<CloudStorageAccount >("account").Is(...)
            .Ctor<string >("containerName").Is(...)
            .Ctor<string >("contentType").Is(...)
            .Ctor<BlobContainerPermissions >("blobContainerPermissions").Is(...);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With