Skip to content

Commit

Permalink
Fixed #241 and #217
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-xu committed Sep 11, 2017
1 parent c10ccf6 commit 68a8ca4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/Ninject.Test/Integration/PropertyInjectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,21 @@ public void ParentPropertiesAreInjected()
warrior.SecretWeaponAccessor.Should().NotBeNull();
warrior.VerySecretWeaponAccessor.Should().NotBeNull();
}


[Fact]
public void GrandParentPropertiesAreInjected()
{
this.kernel.Settings.InjectNonPublic = true;
this.kernel.Settings.InjectParentPrivateProperties = true;
var warrior = this.kernel.Get<GrandFatherStyleNinja>();

warrior.Should().NotBeNull();
warrior.OffHandWeapon.Should().NotBeNull();
warrior.SecondaryWeapon.Should().NotBeNull();
warrior.SecretWeaponAccessor.Should().NotBeNull();
warrior.VerySecretWeaponAccessor.Should().NotBeNull();
}

private class OwnStyleNinja : Ninja
{
public OwnStyleNinja(IWeapon weapon)
Expand All @@ -171,6 +185,14 @@ public FatherStyleNinja(IWeapon weapon)
{
}
}

private class GrandFatherStyleNinja : FatherStyleNinja
{
public GrandFatherStyleNinja(IWeapon weapon)
: base(weapon)
{
}
}
#endif //!SILVERLIGHT
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ninject/Selection/Selector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public virtual IEnumerable<PropertyInfo> SelectPropertiesForInjection(Type type)
{
for (Type parentType = type.GetTypeInfo().BaseType; parentType != null; parentType = parentType.GetTypeInfo().BaseType)
{
properties.AddRange(this.GetPrivateProperties(type.GetTypeInfo().BaseType));
properties.AddRange(this.GetPrivateProperties(parentType));
}
}

Expand Down

0 comments on commit 68a8ca4

Please sign in to comment.