Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-xu committed Nov 22, 2017
1 parent df500eb commit 9269fc2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
- Call `kernel.Get<T>()` two times do not give the same result [#262](https://github.com/ninject/Ninject/issues/262)

## [3.3.4] - 2017-11-13

### Fixed
Expand Down
45 changes: 45 additions & 0 deletions src/Ninject.Test/Integration/CacheInstanceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace Ninject.Tests.Integration.ExternalInjectionTests
{
using System;

using Ninject.Tests.Fakes;
using Xunit;

public class CacheInstanceContext : IDisposable
{
protected StandardKernel kernel;

public CacheInstanceContext()
{
this.kernel = new StandardKernel();
}

public void Dispose()
{
this.kernel.Dispose();
}
}

public class WhenResolveWithPropertyInjection : CacheInstanceContext
{
[Fact]
public void ShouldThrowActivationExceptionTheSecondTime()
{
this.kernel.Bind<SomeWarrior>().ToSelf().InSingletonScope();
try
{
this.kernel.Get<SomeWarrior>();
}
catch (ActivationException)
{
}

Assert.Throws<ActivationException>(() => this.kernel.Get<SomeWarrior>());
}
}

public class SomeWarrior
{
[Inject] public IWeapon Weapon { get; set; }
}
}
10 changes: 5 additions & 5 deletions src/Ninject/Activation/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,18 @@ private object ResolveInternal(object scope)
return null;
}

if (scope != null)
{
this.Cache.Remember(this, reference);
}

if (this.Plan == null)
{
this.Plan = this.Planner.GetPlan(reference.Instance.GetType());
}

this.Pipeline.Activate(this, reference);

if (scope != null)
{
this.Cache.Remember(this, reference);
}

return reference.Instance;
}

Expand Down

0 comments on commit 9269fc2

Please sign in to comment.