Consider the following class
public class SchemaExecutor: ISchemaExecutor
{
public SchemaExecutor(SqlPlusSettings sqlPlusSettings)
{
_sqlPlusSettings = sqlPlusSettings;
}
...
And container configuration
ObjectFactory.Initialize( x =>
{
SqlPlusSettings sqlPlusSettings = GetSqlPlusSettings();
x.ForRequestedT...
I am in the middle of moving over a large body of code to Castle Trunk which includes the new fluent interface for configuring the container. Since the project has a huge windsorConfig xml file that is beyond maintainable, I thought I would start to take advantage of this new feature. I know other containers (e.g. StructureMap 2.0) also ...
Hello,
I am just trying out structuremap and would like to be able to see which of my classes are registered for which service.
For example with castle windsor I can bring up the debugger and view container.Kernel.GraphNodes to see a list of all currently registered service/type pairings.
Is there a similar view into StructureMap inter...
Is it possible to use the syntax
using(_mocks.Record())
{
//...
}
using(_mocks.Playback())
{
//...
}
with StructureMap RhinoAutoMocker?
In Jeremy Millers original post AutoMocker in StructureMap 2.5 this seems possible since RhinoAutoMocker inherits MockRepository, but in version 2.5.2 of StructureMap this seems to be implemen...
This is my StructureMap bootstrapping:
ObjectFactory.Initialize(factory =>
{
//Business Conversation is per session
factory.ForRequestedType<IConversation>().
TheDefaultIsConcreteType<Conversation>().
CacheBy(InstanceScope.HttpSession);
//Session Factory is life time
factory.ForRequestedType<INHibernateSessionManager>...
I'm working on an asp.net-mvc application. The linq data context is being passed into my service objects by structure map. I've got is set to have a scope of hybrid. This all works just fine.
protected override void configure()
{
ForRequestedType<AetherDataContext>()
.TheDefaultIs(() => new AetherDataContext())
.CacheBy(Instan...
So, I have a .NET solution that uses StructureMap, and I'd like to have StructureMap read an outside assembly that implements an interface from a project in that solution and defines the registry entry for it.
StructreMap configuration for my solution:
ObjectFactory.Initialize(registry =>
{
registry.Scan(assembly =>
{
assembl...
I've implemented my own copy of the model view presenter pattern (in vein of web client software factory) so I can leverage my own DI framework instead of being tied to WCSF's ObjectBuilder which I had numerous problems with. I've come up with a few ways to do it but none of them particularly make me happy. I wanted to know if anyone els...
Hi,
I've got an interface:
IRepository<T> where T : IEntity
while im knocking up my UI im using some fake repository implementations that just return any old data.
They look like this:
public class FakeClientRepository : IRepository<Client>
At the moment im doing this:
ForRequestedType<IRepository<Client>>()
.TheDefaultIsConc...
important; I'm really looking for a StructureMap answer here. Please don't say how to do it with Windsor, Spring, Unity, or any of the others.
I'm playing with StructureMap for IoC - and basically my aim is to have a "default" profile that defines the core types, and a number of named profiles that override/extend this. I think that pro...
How can I add some scoping when I scan my assemblies ? Google doesn't seem quite happy with "structuremap scan cacheby" :/
ObjectFactory.Configure(registry =>
{
registry.Scan(x =>
{
x.AssemblyContainingType(typeof(IRepository<>));
x.With<DefaultConventionScanner>();
});
}
...
Hi,
I am struggling with setting up StructureMap without the use of the
generic fluent interface,
I can't use the generic methods, because I don't know the types at
design time.
Ie:
To choose a default constructor the only method I could find is using
'SelectConstructor<T>()', but I only know the type at runtime...
This is related: ...
I am trying to use StructureMap and have essentially 3 levels of abstraction. I have a service a repository and database interface. So the IService depends on IRepo and IRepo depends on IDatabase. My issue is that my IDatabase concrete type takes in db connection information. I am going to create these on the fly, trying to use Object...
I have the concrete types for interfaces configured at startup, but I want to create instances of the concrete type at runtime with setting properties or setting different values in the constructor. All the creating of instances I see have the knowledge of what the concrete type is, at runtime I dont know the concrete type. Is there a ...
I'm trying to use StructureMap's InstanceScope.HttpSession feature and I'm running into problems. I have the following method I'm using for testing:
public static class StructureMapTest {
public static T Get<T>() {
ObjectFactory.Configure(x => x.AddRegistry(new RepositoryRegistry()));
return ObjectFactory.GetInstanc...
My views extend a base view class ive made:
public class BaseView : ViewPage
At the moment im calling ObjectFactory.GetInstance inside this class' constructor to get some interface implementations but id like to use structuremap to inject them as constructor arguments.
Im using a structuremapcontrollerfactory to create my controllers...
i have this:
SetAllProperties(x =>
{
x.WithAnyTypeFromNamespace("mynamespace");
});
And i intend to use BuildUp to get structuremap to apply this policy to a particular object.
However, because i've got the above code in my registry, won't structuremap try to do setter injection on all...
I'm trying to get structuremap to correctly create my controllers, I'm using DI to inject an INewsService into a NewsController and thats the only constructor I have.
public class NewsController : Controller
{
private readonly INewsService newsService;
public NewsController(INewsService newsService)
{
this.newsService ...
I am look for some Structure map Tutorials.
Does anyone know of any?
EDIT: All answers are appreciated but I was looking for something that is not on the first 2 pages of Google. I would have the sense to do that first.
...
When defining bindings for types that requires ctor arguments for the default instance it's pretty clear how to do it. However, when I want to create alternative profiles it gets a bit more difficult.
This is how it's done for a default instance:
ForRequestedType(typeof (IRepository<>))
.TheDefaultIsConcreteType(typeof (SpRepositor...