Questions tagged [property-injection]
61 questions
1
vote
3 answers
Is property injection a kind of dependency injection in Spring?
XML
JAVA
package com.company;
// ...
public class HelloWorld {
private String msg;
public void setMsg(String msg) { this.msg =…

H. Guo
- 63
- 1
- 8
1
vote
1 answer
Evaluate properties in Spring's context.xml (basic templating)
I'm wondering whether it is possible to evaluate properties in Spring's xml configuration files. I'm currently already injecting properties using a PropertyPlaceholderConfigurer. But what I want to achieve is to inject a value, if a certain property…

dpr
- 10,591
- 3
- 41
- 71
1
vote
2 answers
Asp.Net Web Api and Autofac with Custom Authorisation attribute issue (property injection)
I am using Autofac to inject all my project dependencies which is working great. Now I have added a Custom Authorization attribute (I don't need very complex functionality like OWIN and Identity stuff). The custom authorization attribute has…

user1829319
- 691
- 1
- 8
- 22
1
vote
1 answer
Ninject cyclic dependency - already using property injection
I'm having a problem with a cyclic dependency in a project using dependency injection. In looking around, it seems that the only way to avoid it, other than restructuring (I did some of that too), is to use property injection. I tried this, and it…

Ixonal
- 616
- 8
- 18
1
vote
1 answer
How to inject only one property into class
I have a class
class A{
private Foo foo;
private Bar bar;
private Baz baz;
}
Now this class has constructor that initializes foo and bar. Baz however has an DataSource field which I want o be injected with spring.
The A class…

mCs
- 167
- 1
- 4
- 16
1
vote
1 answer
Property Injection and/or Adding a Controller to an Alternate MenuItem View
I'm trying (and failing) to get property injection working in Orchard CMS.
This is necessary, because the below code is acting something like a code-behind for a view (horrible I know). The reason being that the view doesn't have a controller that I…

jimasp
- 962
- 9
- 26
1
vote
0 answers
Configure decorators with NServiceBus DI
How can I configure NServiceBus to inject decorated classes correctly?
Imagine this scenario:
public class A
{
public IDependency Dependency {get;set;}
}
public class B : IDependency
{
public IDependency DecoratedDependency {get;…

Sam Holder
- 32,535
- 13
- 101
- 181
0
votes
1 answer
MEF property injection doesn't occur
I have a problem when retrieving information from an imported attribute. The attribute remains null after calling .ComposeParts(), but the composition is OK, because I can call .GetExportedValues() afterwards and I get the needed instance. Here is…

Jan Kratochvil
- 2,307
- 1
- 21
- 39
0
votes
1 answer
Property injection with Autofac and ASP.NET Core controller
My controller classes have a single dependency, e.g.:
public class UserController : ControllerBase {
public UserController(IMediator mediator) => _mediator = mediator;
private readonly IMediator _mediator;
}
But that must be duplicated in all…

lonix
- 14,255
- 23
- 85
- 176
0
votes
1 answer
How to properly do property injection of an object in AppDelegate.swift
I try to create an instance of RootViewModel once by injecting it in the RootViewController when the app launches, in the didFinishLaunchingWithOptions of AppDelegate.swift so it doesn't get created multiple times.
Here's the code snippet:
...
var…

Waheed
- 41
- 2
- 8
0
votes
1 answer
How to configure xml file for Spring.Net property injection
I need to use spring.net to inject dependencies for the implementation of interfaces, using property injection. I am not really familiar with it, can someone kindly explain it to me?
So in the config xml file, the object is the class that is…

pepega
- 25
- 8
0
votes
1 answer
Why is IObjectMapper not initialised when unit testing a controller method?
I am using ASP.NET Boilerplate template for ASP.NET Core. I have some application services which I have successfully unit tested.
I now want to test a controller method which uses these application services.
The controller method includes mapping…

Conor McCarthy
- 232
- 3
- 12
0
votes
2 answers
Injecting Connection String from config file into EF Core DbContext
I have a need to inject a dependency into my DbContext Class for my project. I am trying to do this in a way that follows "Clean Architecture".
I need to be able to use the DbContext's empty constructor and still reference the connection string…

Zach Painter
- 180
- 1
- 9
0
votes
1 answer
When is it appropriate to use local defaults in a class that relies on dependency injection
Imagine the following constuctor
public RestClient(
string key,
Uri baseAddress,
IHttpClient httpClient,
ISerializer serializer,
IResponseFactory responseFactory)
{
_key = key;
_baseAddress = baseAddress;
_httpClient…

user3154431
- 308
- 3
- 8
0
votes
1 answer
Accessing a base class property that is defined with Property Injection in the base class's constructor
I've read through everything on the ninject wiki and lots of posts and still don't understand how to set up injection so that I can reference this property. I want to be able to reference the property in the base class constructor to ultimately set…

RCM01
- 3
- 1