Skip to content

Commit

Permalink
Update evaluation of null values [Issue #73]
Browse files Browse the repository at this point in the history
  • Loading branch information
intentor committed Mar 1, 2017
1 parent 20670f7 commit 9e754b4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Assets/Adic/Scripts/Framework/Injection/Injector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,10 @@ protected void InjectFields(object instance, AcessorInfo[] fields) {
var field = fields[fieldIndex];

var value = field.getter(instance);
if (value == null || "null".Equals(value.ToString())) {

//The Equals(null) comparison is used to ensure correct null evaluation due to the null trick
//Unity uses for objects derived from UnityEngine.Object.
if (value == null || value.Equals(null)) {
var valueToSet = this.Resolve(field.type, InjectionMember.Field, field.name, instance,
field.identifier, false);
field.setter(instance, valueToSet);
Expand All @@ -360,7 +363,10 @@ protected void InjectProperties(object instance, AcessorInfo[] properties) {
var property = properties[propertyIndex];

var value = property.getter == null ? null : property.getter(instance);
if (value == null || "null".Equals(value.ToString())) {

//The Equals(null) comparison is used to ensure correct null evaluation due to the null trick
//Unity uses for objects derived from UnityEngine.Object.
if (value == null || value.Equals(null)) {
var valueToSet = this.Resolve(property.type, InjectionMember.Property, property.name, instance,
property.identifier, false);
property.setter(instance, valueToSet);
Expand Down

0 comments on commit 9e754b4

Please sign in to comment.