@@ -51,10 +51,10 @@ public override IUnityContainer Populate(IUnityContainer container)
5151 }
5252
5353 /// <summary>
54- /// Create a list of <see cref="InstanceToRegister"/> depending on class marked with <see cref="RegisterInstanceProviderAttribute"/>
54+ /// Create a list of <see cref="InstanceToRegister" /> depending on class marked with <see cref="RegisterInstanceProviderAttribute" />
5555 /// </summary>
56- /// <param name="container"><see cref="IUnityContainer"/> to resolve <paramref name="providerClassType"/></param>
57- /// <param name="providerClassType">Class type used to search for <see cref="RegisterInstanceAttribute"/></param>
56+ /// <param name="container"><see cref="IUnityContainer" /> to resolve <paramref name="providerClassType" /></param>
57+ /// <param name="providerClassType">Class type used to search for <see cref="RegisterInstanceAttribute" /></param>
5858 /// <returns>List of instances to register with all needed parameters</returns>
5959 /// <exception cref="InvalidOperationException"><paramref name="providerClassType" /> type must not be static or abstract.</exception>
6060 private IEnumerable < InstanceToRegister > GetInstancesToRegisterFor ( IUnityContainer container , Type providerClassType )
@@ -65,24 +65,28 @@ private IEnumerable<InstanceToRegister> GetInstancesToRegisterFor(IUnityContaine
6565 $ "Class type must not be static or abstract to be used with RegisterTypeAttribute: { providerClassType . FullName } ") ;
6666 }
6767
68- object providerClassInstance = container . Resolve ( providerClassType ) ;
69- PropertyInfo [ ] properties = providerClassType . GetProperties ( ) ;
70-
71- return properties . Where ( info => info . CustomAttributes . Any ( data => data . AttributeType == typeof ( RegisterInstanceAttribute ) ) )
72- . Select ( info =>
73- {
74- object instance = info . GetValue ( providerClassInstance ) ;
75- RegisterInstanceAttribute attribute = info . GetCustomAttribute < RegisterInstanceAttribute > ( ) ;
76- Type from = attribute . From ;
77- IInstanceLifetimeManager lifetimeManager = attribute . LifetimeManager == null ? null : GetInstanceByType < IInstanceLifetimeManager > ( attribute . LifetimeManager ) ;
78-
79- return new InstanceToRegister ( instance , from , lifetimeManager ) ;
80- } )
81- . ToList ( ) ;
68+ object providerClassInstance = container . Resolve ( providerClassType ) ;
69+ PropertyInfo [ ] properties = providerClassType . GetProperties ( ) ;
70+
71+ return properties
72+ . Where ( info => info . CustomAttributes . Any ( data => data . AttributeType == typeof ( RegisterInstanceAttribute ) ) )
73+ . Select ( info =>
74+ {
75+ object instance = info . GetValue ( providerClassInstance ) ;
76+ RegisterInstanceAttribute attribute = info . GetCustomAttribute < RegisterInstanceAttribute > ( ) ;
77+ Type from = attribute . From ;
78+ IInstanceLifetimeManager lifetimeManager =
79+ attribute . LifetimeManager == null
80+ ? null
81+ : GetInstanceByType < IInstanceLifetimeManager > ( attribute . LifetimeManager ) ;
82+
83+ return new InstanceToRegister ( instance , from , lifetimeManager ) ;
84+ } )
85+ . ToList ( ) ;
8286 }
8387
8488 /// <summary>
85- /// Wrapper to regsiter isntances
89+ /// Wrapper to regsiter isntances
8690 /// </summary>
8791 private sealed class InstanceToRegister
8892 {
@@ -96,19 +100,19 @@ public InstanceToRegister([CanBeNull] object instance,
96100 }
97101
98102 /// <summary>
99- /// Concrete instance to register
103+ /// Concrete instance to register
100104 /// </summary>
101105 [ CanBeNull ]
102106 public object Instance { get ; }
103107
104108 /// <summary>
105- /// Requested type
109+ /// Requested type
106110 /// </summary>
107111 [ CanBeNull ]
108112 public Type Type { get ; }
109113
110114 /// <summary>
111- /// Used lifetime manager
115+ /// Used lifetime manager
112116 /// </summary>
113117 [ CanBeNull ]
114118 public IInstanceLifetimeManager LifetimeManager { get ; }
0 commit comments