I am open to other IoC containers, such as NInject and StructureMap if they are much cleaner than this. I hear that StructureMap just introduced "containers" that may simplify this , perhaps?
As the title says, is there a better way? This seems like a lot of code, just to register an object that requires a factory to create it.
// Th...
Here's the simple test to reproduce the issue, this is the single class in the whole project and there are no other references:
[TestFixture]
public class ObjectFactoryTests
{
[Test]
public void ResetMemoryLeak()
{
for (int i = 1; i < 1000; i++)
{
ObjectFactory.Reset();
if (i % 10 == 0...
I currently have a bunch of repositories like so
IMyRepository
IAnotherRepository
They all inherit from IRepository (if this helps)
How can I get structuremap to use an IRegistryConvention scanner to register my concrete types which are named
SqlMyRepository
SqlAnotherRepository
...
What is the best approach to bootstrap a dll using structuremap? I don't really want the consumers of the library to have to configure anything themselves if they don't want to. I am thinking that the .config would likely be the simplest, but then again 2.6.1 is out and I am not familiar with many of its features / changes yet.
...
I have a default concrete type defined in a registry:
ForRequestedType<IXRepository>()
.TheDefaultIsConcreteType<CacheXRepository>();
The ChaceXRepository has the following constructor:
public class CacheXRepository: IXRepository{
public CacheXRepository(IXRepository xRepository,ICache cacheService){
In the constru...
Hi,
I am currently setting the connection string for my linq to sql data context by using a wrapper class so that I can pass a connection string into the generated DataContext constructor:
public class DB : GeneratedDataContext {
public DB() : base(ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString) {...
Has anyone gotten the NH session management bits from RhinoCommons to work with Structure Map? We already use SM and do not want a dependency on Windsor.
...
I'm having difficulty conditionally creating a dependency. Googling, I have yet to find a good example of using the BuildStack and Conditional Predicates.
Here's what I'm doing in the Registry:
//snip
public SomeRegistry()
{
this.InstanceOf<IFoo>().Is.Conditional(
c =>
{
c.TheDefault.Is.Constru...
Is there any way to request an instance from the StructureMap ObjectFactory by the string name of the type? For example, it would be nice to do something like this:
var thing = ObjectFactory.GetInstance("Thing");
The use case here is a messaging scenario in which the message is very generic and contains only the name of a task. A ha...
I am currently following instructions in a book to develop an application. It asks me to download StructureMap and then move the StructureMap.Dll file and the Log4Net.dll into the bin files. The problem is there doesnt seem to be a Log4Net.dll file in the StructureMap files, the only other dll apart from the StructureMap.dll is the Rhino...
I just used StructureMap few days ago. I use StructureMap for collecting all validator class like the following code.
public class BaseClassA {}
public class ClassB : BaseClassA {}
public class ClassC : BaseClassB {}
public BaseClassAValidator : IValidator<BaseClassA>() {}
In StructureMap, I only register IValidator interface for B...
I'm getting a the following exception:
"Timeout Expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled conections were in use and max pool size was reached."
...from a relatively heavily trafficked ASP.NET MVC 2 site I developed using StructureMap and Fluent NHiber...
I have a registry class like this:
public class StructureMapRegistry : Registry
{
public StructureMapRegistry()
{
For<IDateTimeProvider>().Singleton().Use<DateTimeProviderReturningDateTimeNow>();
}
I want to test that the configuration is according to my intent, so i start writing a test:
public class WhenConfigur...
Hi folks,
I've got a winform app in visual studio 2010. My app does the following
Get a list of files which I need to read the data then insert into a database.
For each file, read data and insert into DB.
So .. this is the code i have.
// *******
// *** How should the _repository be Injected??
// *******
var list = _repository.Get...
I'm trying to use StructureMap with nServiceBus.
The Project:
Uses a GenericHost Endpoint to send command messages
Configures nServiceBus using the StructMapBuilder.
Uses a simple StructureMap registry config
Uses a start up class TestServer supporting IWantToRunAtStartup
The TestServer class has ctor dependency on a TestManager clas...
I use the following:
public interface IRepository<T>
{
void Add(T entity);
}
public class Repository<T>
{
private readonly ISession session;
public Repository(ISession session)
{
this.session = session;
}
public void Add(T entity)
{
session.Save(entity);
}
}
public class SomeHandler : IHandleMessages<SomeMe...
So I already have a working implementation of StructureMap with the WCF service (including custom instance provider, behaviors, etc.)
When I try to have an object that is instantiated only once per user request, I use the InstanceScope.HttpContext and it throws because the context is null.
Do anyone have a proper way of doing that?
...
We are building an ASP.NET project, and encapsulating all of our business logic in service classes. Some is in the domain objects, but generally those are rather anemic (due to the ORM we are using, that won't change). To better enable unit testing, we define interfaces for each service and utilize D.I.. E.g. here are a couple of the ...
Are there any frameworks that assist me with this: (thinking that perhaps StructureMap can help me)
Whenever I create a new instance of "MyClass" or any other class that inherits from IMyInterface I want all properties decorated with [MyPropertyAttribute] to be populated with values from a database or some other data storage using the p...
I'll start by telling my project setup:
ASP.NET MVC 1.0
StructureMap 2.6.1
VB
I've created a bootstrapper class shown here:
Imports StructureMap
Imports DCS.Data
Imports DCS.Services
Public Class BootStrapper
Public Shared Sub ConfigureStructureMap()
ObjectFactory.Initialize(AddressOf StructureMapRegistry)
End Su...