@@ -15,6 +15,40 @@ private interface IService
15
15
{
16
16
}
17
17
18
+ private interface IAutoWiredService
19
+ {
20
+ bool NestedServiceIsNotNull ( ) ;
21
+ }
22
+
23
+ private class NestedService
24
+ {
25
+ }
26
+
27
+ private class AutoWiredService : IAutoWiredService
28
+ {
29
+ public NestedService NestedService { get ; set ; }
30
+
31
+ public bool NestedServiceIsNotNull ( )
32
+ {
33
+ return NestedService != null ;
34
+ }
35
+ }
36
+
37
+ private class AutoWiredServiceDecorator : IAutoWiredService
38
+ {
39
+ private readonly IAutoWiredService _original ;
40
+
41
+ public AutoWiredServiceDecorator ( IAutoWiredService original )
42
+ {
43
+ _original = original ;
44
+ }
45
+
46
+ public bool NestedServiceIsNotNull ( )
47
+ {
48
+ return _original . NestedServiceIsNotNull ( ) ;
49
+ }
50
+ }
51
+
18
52
public class Foo
19
53
{
20
54
}
@@ -149,6 +183,36 @@ public void RegistrationTargetsTheImplementationType()
149
183
Assert . Equal ( typeof ( ImplementorA ) , registration . Target . Activator . LimitType ) ;
150
184
}
151
185
186
+ [ Fact ]
187
+ public void DecorateReflectionActivatorWithPropertyInjection ( )
188
+ {
189
+ var builder = new ContainerBuilder ( ) ;
190
+ builder . RegisterType < NestedService > ( ) ;
191
+ builder . RegisterType < AutoWiredService > ( ) . As < IAutoWiredService > ( ) . PropertiesAutowired ( ) ;
192
+ builder . RegisterDecorator < AutoWiredServiceDecorator , IAutoWiredService > ( ) ;
193
+
194
+ var container = builder . Build ( ) ;
195
+
196
+ var service = container . Resolve < IAutoWiredService > ( ) ;
197
+
198
+ Assert . True ( service . NestedServiceIsNotNull ( ) ) ;
199
+ }
200
+
201
+ [ Fact ]
202
+ public void DecorateProvidedInstanceActivatorWithPropertyInjection ( )
203
+ {
204
+ var builder = new ContainerBuilder ( ) ;
205
+ builder . RegisterType < NestedService > ( ) ;
206
+ builder . RegisterInstance < IAutoWiredService > ( new AutoWiredService ( ) ) . PropertiesAutowired ( ) ;
207
+ builder . RegisterDecorator < AutoWiredServiceDecorator , IAutoWiredService > ( ) ;
208
+
209
+ var container = builder . Build ( ) ;
210
+
211
+ var service = container . Resolve < IAutoWiredService > ( ) ;
212
+
213
+ Assert . True ( service . NestedServiceIsNotNull ( ) ) ;
214
+ }
215
+
152
216
private abstract class Decorator : IDecoratedService
153
217
{
154
218
protected Decorator ( IDecoratedService decorated )
0 commit comments