Questions tagged [property-injection]

61 questions
3
votes
3 answers

Use Spring Data random (embedded) Mongo port with NoSQL JUnit @Rule

I'm currently trying to write an Integration test class which uses Spring Data Mongo repositories. I use an embedded Mongo instance provided by the de.flapdoodle.embed.mongo dependency. Spring Data documentation specifies that we only have to put…
Lebowski
  • 588
  • 7
  • 21
3
votes
3 answers

How to resolve property injection with Autofac?

I have an MVC web app which uses Autofac to inject services in controllers. The problem: I am trying to do property injection on a service and it fails (the property is always null). What I expect: I expect to have the property initialized properly…
3
votes
3 answers

Programatic property injection with Microsoft Unity

I use contructor injection in my solution, but this one class has a property that i do not want to pass in the constructor where i have the invariant dependencies. Let's say i got an ILogger and it has a FileName property i want to set, while still…
2
votes
0 answers

How to use property injection in unity and asp.net mvc3?

I would like to use property injection in an MVC3 application. I have configured Unity 2 as a DI container and everything works just fine by constructor injection but I can't figure out how to use property injection. I marked properties with the…
2
votes
3 answers

UnityContainer.BuildUp() - Can I make it inject new instances into properties only if these are null?

I'm deserializing a class like this one class AClass{ [Dependency] AnotherClass Property{ get; set; } } When I then BuildUp() the object I'd like Unity to create a new instance of AnotherClass only if the property is null and otherwise just…
Roald
  • 1,722
  • 11
  • 21
2
votes
0 answers

Unity InjectionProperty generates null property

The various posts here do not show why every time I attempt to use the InjectionProperty() construct in Unity 2.0 (April) it never populates the properties in my resolved instance. They are always null. I can see in the debugger that the object is…
2
votes
0 answers

Requiring an attribute for CastleWindsor property injection

Although I prefer constructor injection, I want developers on my team to be able to use property injection as long as they explicitly mark the property as injectable with an attribute. According to CastleWindsor documentation here, this should be…
2
votes
1 answer

Windsor Func property injection

Using Windsor 2.5.2, the following works: public class Foo { public IBar Bar { get; set; } } To delay creation of IBar, this also works: public class Foo { public Foo(Func barFactory) { } } However, if I combine property…
Paul Stovell
  • 32,377
  • 16
  • 80
  • 108
2
votes
1 answer

Property injection in static class with Simple Injector

I have used dependency injection from simple injector. Now I am trying to implement property injection but the help document is not helping much. Can anyone explain with simple example how property injection work? I want to use it in one Utility…
Dhwani
  • 7,484
  • 17
  • 78
  • 139
2
votes
1 answer

Property injected value is null in constructor

I'm wiring up Autofac dependency injection within my ASP.NET MVC 5 web application using OWIN middleware (so using startup.cs instead of global.asax), and trying to use property injection to set a public variable within a Controller. I'm playing…
2
votes
1 answer

Cyclic dependency via property injection in Castle Windsor

I have a need for a cyclic dependency in Windsor. This is on purpose for a recursive approach. Module A calls Modules B-F and Module B needs to call back into A because of a tree of nodes. Anyway, I know I can't use constructor injection because of…
2
votes
2 answers

How to prevent Castle Windsor from injecting property dependencies?

Is there a way to prevent Castle Windsor from automatically injecting dependencies into properties (besides the [DoNotWire] attribute)?
1
vote
1 answer

StructureMap property setter injection with open generic using FillAllPropertiesOfType

I have the following class: public abstract class Query { protected abstract TResult Result(); public TResult Execute() { return Result(); } public ISession Session { get; set; } } I wanted to use property…
CraftyFella
  • 7,520
  • 7
  • 47
  • 61
1
vote
1 answer

Best Design For Constantly Changing Property Within A Singleton Class With IoC Usage?

I have the following helper class which has public property _variableHandler. The property is public as I initially had visions of setting the property from the calling code before involving methods within the XAMLHelper class, but now doubt this is…
1
vote
1 answer

DryIoC won't inject properties into ASP.NET Core MVC controller

I'm using https://bitbucket.org/dadhi/dryioc/src/589e7c0b356a/NetCore/src/DryIoc.AspNetCore.Sample as baseline. Tried to implement an attribute-based property injection selector with the following: private static PropertyOrFieldServiceInfo…