I have something like this:
public interface IBaseService<TObject>
public class BaseService<TObject, TRepository> : IBaseService<TObject>
where TRepository : IRepository<TObject>
I need to register BaseService To IBaseService
(the IRepository<> is registered)
...
I have several dependency injection services which are dependent on stuff like HTTP context. Right now I'm configuring them as singletons the Windsor container in the Application_Start handler, which is obviously a problem for such services.
What is the best way to handle this? I'm considering making them transient and then releasing th...
Which Dependency Injection frameworks are compatible (and tested) against the Mono 2.4.2.3 runtime (Release Notes)?
...
What should I be careful about when building a class library complex enough to use internal dependency injection?
Assuming that it will use Castle Windsor (as an example), what would be the best place/method to configure the container, given that the library will be used by simple console application (with no DI), web forms using the sa...
I'm currently getting an error trying to resolve my IDataAccess class.
The value of the property 'type' cannot be parsed. The error is: Could not load file or assembly 'TestProject' or one of its dependencies. The system cannot find the file specified.
(C:\Source\TestIoC\src\TestIoC\TestProject\bin\Debug\TestProject.vshost.exe.config li...
I'm going to use structuremap for a project I'm working on. The basic gist is that I have a repository pattern with an NHibernate implementation, but I want to use StructureMap to load the repositories in case I ever decide to switch to a Linq2Sql or other type of implementation. I know how to initialize structuremap, but my question is ...
Hello!
As I understand IoC-container is helpful in creation of application-level objects like services and factories. But domain-level objects should be created manually.
Spring's manual tells us: "Typically one does not configure fine-grained domain objects in the container, because it is usually the responsibility of DAOs and business...
Dear all,
I am trying to use StructureMap ExplictArguments class to pass them on runtime and based on them, I want that structure map concludes which constructor should be launched. My test scenario is:
public class SpecialClass : ISpecialClass //this is test class, has two constructors
{
public SpecialClass()
{
}
...
I am trying to create an interface wrapper for my IOC container so I do not have to have a dependency on a particular one. My problem is that some of the service classes I have take in a companyID which is a string. I want to make generic interface methods like
T Resolve<T>() where T is the service interface.
Right now I use Struc...
Hi All,
How do you determine which classes should be constructed through an IOC container, and which ones shouldn't. I've worked on projects with both extremes and it seems like interfaces should only be used when the classs specifies a specific technoliogy like logging or data access?
Where do people draw the line between the two?
...
Hi,
I have the following setup:
@Component
public class ImplOne implements IFace{
}
@Component
public class ImplTwo implements IFace{
}
public interface IFace{
}
I am trying to get a reference of ImplOne by type:
@RunWith(SpringJUnit4ClassRunner.class)
public class ImplOneTest {
@Autowired
private ImplOne impl;
@Test
publ...
I am trying to figure out how to use IoC in situations where the dependent classes can change based on some variable in the application (in this case, Session state). For example, each of our clients have a different database, so the connection to the database needs to be built on a value stored in their Session (particularly since some...
Hi,
I'd like to use a mocking framework as well as an IOC framework with my latest project, based on subsonic 3 (ActiveRecord) and ASP.NET MVC.
I'd like to use Moq for mocking and Castle-Windsor for IOC.
Anyone got any advice or recommendations based on these choices? Any bumps in the road I should be aware of?
Chris
...
I am currently into the testing stage of a project I am working on and am having trouble bringing the main service under test in anything other than the most basic default test cases.
The Service is currently responsible for the creation of all sub-components, which I would like to change to use an IoC container.
What container should...
I want to refactor some code using the Windsor IOC/DI framework, but my issue is that I have some Singleton classes and Factory pattern classes and I am not sure that one can implement a Singleton or Factory using DI.
Has anyone any ideas if that is possible and how?
...
Is there a way via xml configuration to denote a static factory method on an object?
...
I want to create a class, that is flexible so I can switch implementations.
Problem: Store files/documents
Options: either store locally on the server filesystem, database or etc.
Can someone help with a skeleton structure of the class, and how I would call it?
I am not using an IoC, and don't really want to just yet. I just want the...
I'm using StructureMap to Enrich some of my objects with an instance call to
ProxyGenerator.CreateInterfaceProxyWithTarget(myObject, MYInterceptor)
Currently I have the MYInterceptor inside my container, should I implement any type of caching for the interceptor?
The second question should I register my ProxyGenerator inside my contai...
If there are 3 interfaces like the following
public interface IWeapon {
void Kill();
}
public interface ISword:IWeapon {
void Slice();
}
public interface IShuriken: IWeapon {
void Pierce();
}
public class Ninja {
public IWeapon Weapon {get;set;}
public void BrutalKill() {
/* warrior must pierce, pierce, pierce and then kill
*/
}...
So suppose my sandwich shop has two service interfaces, IMeatGetter and IVeggiesGetter. Now I have a domain object, Sandwich, with a property IsVegetarian. I want a method to select all the possible toppings, like
void GetToppings
{
if IsVegetarian
select (veggies)
else
select (veggies union meats)
}
Is it correct domain...