In my last project we used MSBuild as a scripting language. (yeah, really!) We also wrote hundreds of custom MSBuild tasks, for the parts that made more sense in C#. (I even wrote an MSBuild task to generate the boilerplate code for an MSBuild task. Yes, it consumed itself.)
While I don't recommend anyone else take this same approach, ...
Hi all.
I have a singleton bean definition like this:
<bean id="exampleBean" class="com.examples.ExampleBean">
<property name="exampleBean2">
<bean class="com.examples.ExampleBean2" />
</property>
</bean>
where ExampleBean could be:
public class ExampleBean {
private ExampleBean2 exampleBean2;
public ExampleBean() { }
...
I have some providers, say -
<Providers>
<Provider Type="Providers.IM" Name="Im"/>
<Provider Type="Providers.Web" Name="Web"/>
...
</Provider>
Each of these providers can give me a session :
<Sessions>
<Session Name="GoogleIM" Provider="Im" URL="..." />
<Session Name="YahooIM" Provider="Im" URL="..." />
<S...
Having seen how NInject can do it and AutoFac can do it I'm trying to figure out how to inject dependencies into MVC ActionFilters using Castle Windsor
At the moment I'm using an ugly static IoC helper class to resolve dependencies from the constructor code like this:
public class MyFilterAttribute : ActionFilterAttribute
{
priva...
I've used Spring before (and like it), but thought I'd take a look at Guice.
Is there a way to initialize something like maps or lists into beans using Guice?
For instance, I've done the following before in Spring to inject a list of items I want to process into some bean.
<property name="FilesToProcess">
<list>
<value>file1....
Do you find that dependency injection frameworks make code more difficult to follow? Does the indirection outweigh the benefit?
...
Currently there are quite a few DI/IoC-frameworks for .NET out there (http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx).
I find it quite hard to choose. Therefore I wanted to measure the public opinion and see which framework is the most popular - so please post your favorite framework here and let the people ...
Most of the examples quoted for usage of Dependency Injection, we can solve using the factory pattern as well. Looks like when it comes to usage/design the difference between dependency injection and factory is blurred or thin.
Once someone told me that its how you use it that makes a difference!
I once used StructureMap a DI containe...
At my old C++ job, we always took great care in encapsulating member variables, and only exposing them as properties when absolutely necessary. We'd have really specific constructors that made sure you fully constructed the object before using it.
These days, with ORM frameworks, dependency-injection, serialization, etc., it seems like...
I've got a page with a form in Wicket where the form requires a collaborator to get its job done. The collaborator is injected (for which I'm using Guice) and looks something like:
public class RegistrationPage extends WebPage {
@Inject
public RegistrationPage(RegistrationService service) {
this.service = service;
...
When code processes dates based on the current date, testing should cover edge cases such as leap years as well as the more frequent month and year boundaries.
In our code we always get the current date deep down in our classes using DateTime.Now (.NET, in our case).
How can you unit test such code?
Is this where Dependency Injection ...
I'm writing a mid-sized analysis program (5-10kloc) in MATLAB (not my decision), and I'm trying to use dependency injection to make my code more testable. I think I understand the basic object/constructor injection model, but I'm confused as to how this scales up the dependency graph.
For instance, if I have object A, which has-a objec...
I've used Spring and Spring.NET quite a bit, but I would like to see what else is out there. Can anyone recommend a good Java or .NET framework that I could try to learn?
...
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 am trying to work out a way to use Dependency Injection with ASP.NET controls.
I have got lots of controls that create repositories directly, and use those to access and bind to data etc.
I am looking for a pattern where I can pass repositories to the controls externally (IoC), so my controls remain unaware of how repositories are co...
I'm using NInject on a new web application and there are two things that are unclear to me:
Don't I need to keep a reference to the Kernel around (Session/App variable) to insure that GC doesn't collect all my instances? For example, if I specify .Using() and then the Kernel object gets collected, aren't all my "singletons" collected ...
I'd like to create a OnePerSessionBehavior for NInject (v1.0) and I've mostly got it working. The only issue that remains is how to pass in fresh arguments using .WithArguments() as each new session asks for something from the container. Right now I'm keeping a reference to the container as an application variable and therefore the mod...
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...
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 ...
C#, nUnit, and Rhino Mocks, if that turns out to be applicable.
My quest with TDD continues as I attempt to wrap tests around a complicated function. Let's say I'm coding a form that, when saved, has to also save dependent objects within the form...answers to form questions, attachments if available, and "log" entries (such as "blahblah...