Skip to content

@pheiberg /ExampleRegistry.cs
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Extensions for StructureMap registrations
using StructureMap;
using StructureMap.Configuration.DSL;
public class ExampleRegistry: Registry
{
public ExampleRegistry()
{
For<Interface>().Use<Concrete>()
.Ctor<string>("connectionString").EqualToConnectionString("connectionStringKey");
}
}
using StructureMap;
using StructureMap.Pipeline;
using System.Configuration;
public static class StructureMapExtensions
{
public static SmartInstance<T> EqualToConnectionString<T>(this SmartInstance<T>.DependencyExpression<string> dependencyExpression, string key)
{
string connectionString = ConfigurationManager.ConnectionStrings[key].ConnectionString;
return dependencyExpression.Is(connectionString);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.