Skip to content

Commit 3f819c7

Browse files
committed
Changed IInstance provider to take IParameters instead on IConstructorArgument
1 parent 7281fe2 commit 3f819c7

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

src/Ninject.Extensions.Factory/Factory/IInstanceResolver.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ public interface IInstanceResolver
3737
/// <param name="type">The type of the instance.</param>
3838
/// <param name="name">The name of the binding to use. If null the name is not used.</param>
3939
/// <param name="constraint">The constraint for the bindings. If null the constraint is not used.</param>
40-
/// <param name="constructorArguments">The constructor arguments.</param>
41-
/// <param name="fallback">if set to <c>true</c> the request fallsback to requesting instances without
40+
/// <param name="parameters">The constructor arguments.</param>
41+
/// <param name="fallback">if set to <c>true</c> the request falls back to requesting instances without
4242
/// name or constraint if no one can received otherwise.</param>
4343
/// <returns>An instance of the specified type.</returns>
4444
object Get(
4545
Type type,
4646
string name,
4747
Func<IBindingMetadata, bool> constraint,
48-
IConstructorArgument[] constructorArguments,
48+
IParameter[] parameters,
4949
bool fallback);
5050

5151
/// <summary>
@@ -54,15 +54,15 @@ object Get(
5454
/// <param name="type">The type of the instance.</param>
5555
/// <param name="name">The name of the binding to use. If null the name is not used.</param>
5656
/// <param name="constraint">The constraint for the bindings. If null the constraint is not used.</param>
57-
/// <param name="constructorArguments">The constructor arguments.</param>
58-
/// <param name="fallback">if set to <c>true</c> the request fallsback to requesting instances without
57+
/// <param name="parameters">The constructor arguments.</param>
58+
/// <param name="fallback">if set to <c>true</c> the request falls back to requesting instances without
5959
/// name or constraint if no one can received otherwise.</param>
6060
/// <returns>An instance of the specified type.</returns>
6161
object GetAllAsList(
6262
Type type,
6363
string name,
6464
Func<IBindingMetadata, bool> constraint,
65-
IConstructorArgument[] constructorArguments,
65+
IParameter[] parameters,
6666
bool fallback);
6767

6868
/// <summary>
@@ -71,15 +71,15 @@ object GetAllAsList(
7171
/// <param name="type">The type of the instance.</param>
7272
/// <param name="name">The name of the binding to use. If null the name is not used.</param>
7373
/// <param name="constraint">The constraint for the bindings. If null the constraint is not used.</param>
74-
/// <param name="constructorArguments">The constructor arguments.</param>
74+
/// <param name="parameters">The constructor arguments.</param>
7575
/// <param name="fallback">if set to <c>true</c> the request fallsback to requesting instances without
7676
/// name or constraint if no one can received otherwise.</param>
7777
/// <returns>An instance of the specified type.</returns>
7878
object GetAllAsArray(
7979
Type type,
8080
string name,
8181
Func<IBindingMetadata, bool> constraint,
82-
IConstructorArgument[] constructorArguments,
82+
IParameter[] parameters,
8383
bool fallback);
8484
}
8585
}

src/Ninject.Extensions.Factory/Factory/InstanceResolver.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,29 @@ public InstanceResolver(IResolutionRoot resolutionRoot)
5454
/// <param name="type">The type of the instance.</param>
5555
/// <param name="name">The name of the binding to use. If null the name is not used.</param>
5656
/// <param name="constraint">The constraint for the bindings. If null the constraint is not used.</param>
57-
/// <param name="constructorArguments">The constructor arguments.</param>
58-
/// <param name="fallback">if set to <c>true</c> the request fallsback to requesting instances without
57+
/// <param name="parameters">The parameters that are passed to the request.</param>
58+
/// <param name="fallback">if set to <c>true</c> the request falls back to requesting instances without
5959
/// name or constraint if no one can received otherwise.</param>
6060
/// <returns>An instance of the specified type.</returns>
61-
public object Get(Type type, string name, Func<IBindingMetadata, bool> constraint, IConstructorArgument[] constructorArguments, bool fallback)
61+
public object Get(Type type, string name, Func<IBindingMetadata, bool> constraint, IParameter[] parameters, bool fallback)
6262
{
6363
if (fallback && constraint != null)
6464
{
65-
return this.resolutionRoot.TryGet(type, constraint, constructorArguments) ??
66-
this.Get(type, name, null, constructorArguments, name != null);
65+
return this.resolutionRoot.TryGet(type, constraint, parameters) ??
66+
this.Get(type, name, null, parameters, name != null);
6767
}
6868

6969
if (fallback && name != null)
7070
{
71-
return this.resolutionRoot.TryGet(type, name, constructorArguments) ??
72-
this.Get(type, null, null, constructorArguments, true);
71+
return this.resolutionRoot.TryGet(type, name, parameters) ??
72+
this.Get(type, null, null, parameters, true);
7373
}
7474

7575
return constraint == null
7676
? name == null && !fallback
77-
? this.resolutionRoot.Get(type, constructorArguments)
78-
: this.resolutionRoot.Get(type, name, constructorArguments)
79-
: this.resolutionRoot.Get(type, constraint, constructorArguments);
77+
? this.resolutionRoot.Get(type, parameters)
78+
: this.resolutionRoot.Get(type, name, parameters)
79+
: this.resolutionRoot.Get(type, constraint, parameters);
8080
}
8181

8282
/// <summary>
@@ -85,17 +85,17 @@ public object Get(Type type, string name, Func<IBindingMetadata, bool> constrain
8585
/// <param name="type">The type of the instance.</param>
8686
/// <param name="name">The name of the binding to use. If null the name is not used.</param>
8787
/// <param name="constraint">The constraint for the bindings. If null the constraint is not used.</param>
88-
/// <param name="constructorArguments">The constructor arguments.</param>
89-
/// <param name="fallback">if set to <c>true</c> the request fallsback to requesting instances without
88+
/// <param name="parameters">The parameters that are passed to the request.</param>
89+
/// <param name="fallback">if set to <c>true</c> the request falls back to requesting instances without
9090
/// name or constraint if no one can received otherwise.</param>
9191
/// <returns>An instance of the specified type.</returns>
92-
public object GetAllAsList(Type type, string name, Func<IBindingMetadata, bool> constraint, IConstructorArgument[] constructorArguments, bool fallback)
92+
public object GetAllAsList(Type type, string name, Func<IBindingMetadata, bool> constraint, IParameter[] parameters, bool fallback)
9393
{
9494
var listType = typeof(List<>).MakeGenericType(type);
9595
var list = listType.GetConstructor(new Type[0]).Invoke(new object[0]);
9696
var addMethod = listType.GetMethod("Add");
9797

98-
var values = this.GetAll(type, name, constraint, constructorArguments, fallback);
98+
var values = this.GetAll(type, name, constraint, parameters, fallback);
9999

100100
foreach (var value in values)
101101
{
@@ -111,13 +111,13 @@ public object GetAllAsList(Type type, string name, Func<IBindingMetadata, bool>
111111
/// <param name="type">The type of the instance.</param>
112112
/// <param name="name">The name of the binding to use. If null the name is not used.</param>
113113
/// <param name="constraint">The constraint for the bindings. If null the constraint is not used.</param>
114-
/// <param name="constructorArguments">The constructor arguments.</param>
115-
/// <param name="fallback">if set to <c>true</c> the request fallsback to requesting instances without
114+
/// <param name="parameters">The parameters that are passed to the request.</param>
115+
/// <param name="fallback">if set to <c>true</c> the request falls back to requesting instances without
116116
/// name or constraint if no one can received otherwise.</param>
117117
/// <returns>An instance of the specified type.</returns>
118-
public object GetAllAsArray(Type type, string name, Func<IBindingMetadata, bool> constraint, IConstructorArgument[] constructorArguments, bool fallback)
118+
public object GetAllAsArray(Type type, string name, Func<IBindingMetadata, bool> constraint, IParameter[] parameters, bool fallback)
119119
{
120-
var list = this.GetAllAsList(type, name, constraint, constructorArguments, fallback);
120+
var list = this.GetAllAsList(type, name, constraint, parameters, fallback);
121121
return typeof(Enumerable)
122122
.GetMethod("ToArray")
123123
.MakeGenericMethod(type)
@@ -130,29 +130,29 @@ public object GetAllAsArray(Type type, string name, Func<IBindingMetadata, bool>
130130
/// <param name="type">The type of the instance.</param>
131131
/// <param name="name">The name of the binding to use. If null the name is not used.</param>
132132
/// <param name="constraint">The constraint for the bindings. If null the constraint is not used.</param>
133-
/// <param name="constructorArguments">The constructor arguments.</param>
134-
/// <param name="fallback">if set to <c>true</c> the request fallsback to requesting instances without
133+
/// <param name="parameters">The parameters that are passed to the request.</param>
134+
/// <param name="fallback">if set to <c>true</c> the request falls back to requesting instances without
135135
/// name or constraint if no one can received otherwise.</param>
136136
/// <returns>All instances of the specified type.</returns>
137-
private IEnumerable<object> GetAll(Type type, string name, Func<IBindingMetadata, bool> constraint, IConstructorArgument[] constructorArguments, bool fallback)
137+
private IEnumerable<object> GetAll(Type type, string name, Func<IBindingMetadata, bool> constraint, IParameter[] parameters, bool fallback)
138138
{
139139
if (fallback && constraint != null)
140140
{
141-
var result = this.resolutionRoot.GetAll(type, constraint, constructorArguments);
142-
return result.Any() ? result : this.GetAll(type, name, null, constructorArguments, true);
141+
var result = this.resolutionRoot.GetAll(type, constraint, parameters);
142+
return result.Any() ? result : this.GetAll(type, name, null, parameters, true);
143143
}
144144

145145
if (fallback && name != null)
146146
{
147-
var result = this.resolutionRoot.GetAll(type, name, constructorArguments);
148-
return result.Any() ? result : this.GetAll(type, null, null, constructorArguments, true);
147+
var result = this.resolutionRoot.GetAll(type, name, parameters);
148+
return result.Any() ? result : this.GetAll(type, null, null, parameters, true);
149149
}
150150

151151
return constraint == null
152152
? name == null
153-
? this.resolutionRoot.GetAll(type, constructorArguments)
154-
: this.resolutionRoot.GetAll(type, name, constructorArguments)
155-
: this.resolutionRoot.GetAll(type, constraint, constructorArguments);
153+
? this.resolutionRoot.GetAll(type, parameters)
154+
: this.resolutionRoot.GetAll(type, name, parameters)
155+
: this.resolutionRoot.GetAll(type, constraint, parameters);
156156
}
157157
}
158158
}

0 commit comments

Comments
 (0)