From 25a7593bec46e133f0da4704543caddd0895a100 Mon Sep 17 00:00:00 2001 From: Kevin Yockey Date: Mon, 13 Mar 2017 17:57:17 -0700 Subject: [PATCH 1/2] Allow arrays to be resolved as empty --- src/Assets/Adic/Scripts/Framework/Injection/Injector.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Assets/Adic/Scripts/Framework/Injection/Injector.cs b/src/Assets/Adic/Scripts/Framework/Injection/Injector.cs index 6e81183..9ae98b2 100644 --- a/src/Assets/Adic/Scripts/Framework/Injection/Injector.cs +++ b/src/Assets/Adic/Scripts/Framework/Injection/Injector.cs @@ -231,7 +231,9 @@ protected object Resolve(Type type, InjectionMember member, string memberName, o if (bindings == null) { if (alwaysResolve || this.resolutionMode == ResolutionMode.ALWAYS_RESOLVE) { - instances.Add(this.Instantiate(typeToGet)); + if (!type.IsArray) { + instances.Add(this.Instantiate(typeToGet)); + } } else { return null; } @@ -249,7 +251,7 @@ protected object Resolve(Type type, InjectionMember member, string memberName, o if (type != null && !type.IsArray && instances.Count == 1) { resolution = instances[0]; - } else if (instances.Count > 0) { + } else if (type.IsArray) { var array = Array.CreateInstance(typeToGet, instances.Count); for (int listIndex = 0; listIndex < instances.Count; listIndex++) { array.SetValue(instances[listIndex], listIndex); From 937dea1f476f78db2cc7f14ebfab11dffb2d4e89 Mon Sep 17 00:00:00 2001 From: Kevin Yockey Date: Tue, 14 Mar 2017 08:28:28 -0700 Subject: [PATCH 2/2] Checking for the specific case of the property being an array of interfaces. --- src/Assets/Adic/Scripts/Framework/Injection/Injector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Assets/Adic/Scripts/Framework/Injection/Injector.cs b/src/Assets/Adic/Scripts/Framework/Injection/Injector.cs index 9ae98b2..5bbffe9 100644 --- a/src/Assets/Adic/Scripts/Framework/Injection/Injector.cs +++ b/src/Assets/Adic/Scripts/Framework/Injection/Injector.cs @@ -231,7 +231,7 @@ protected object Resolve(Type type, InjectionMember member, string memberName, o if (bindings == null) { if (alwaysResolve || this.resolutionMode == ResolutionMode.ALWAYS_RESOLVE) { - if (!type.IsArray) { + if (!(typeToGet.IsInterface && type.IsArray)) { instances.Add(this.Instantiate(typeToGet)); } } else {