-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Burden.RequiresDecommission is now settable, and if set to false Li…
…fecycledComponentsReleasePolicy will not try to Release the burden, and CreationContext will not add it as child to its potential parents. This enables us: - ILifestyleManager.Release is now called not whenever someone calls kernel.ReleaseComponent or some external signal comes in. It has now more stricter semantics - if it's called, it means that the component really should be released, so { return false; } is rarely a good implementation idea now.
- Loading branch information
Showing
8 changed files
with
159 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/Castle.Windsor.Tests/ClassComponents/HasCtorDependency.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2004-2010 Castle Project - http://www.castleproject.org/ | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace Castle.Windsor.Tests.ClassComponents | ||
{ | ||
using Castle.Windsor.Tests.Components; | ||
|
||
public class HasCtorDependency | ||
{ | ||
public HasCtorDependency(ISimpleService dependency) | ||
{ | ||
Dependency = dependency; | ||
} | ||
|
||
public ISimpleService Dependency { get; private set; } | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...Windsor.Tests/Windsor.Tests/LifecycledComponentsReleasePolicyComponentTrackingTestCase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2004-2010 Castle Project - http://www.castleproject.org/ | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace Castle.Windsor.Tests | ||
{ | ||
using Castle.MicroKernel.Registration; | ||
using Castle.Windsor.Tests.ClassComponents; | ||
using Castle.Windsor.Tests.Components; | ||
|
||
using NUnit.Framework; | ||
|
||
public class LifecycledComponentsReleasePolicyComponentTrackingTestCase : AbstractContainerTestFixture | ||
{ | ||
[Test] | ||
[Ignore("We don't need release policy to track this guy. If we don't though, we can't check if it's tracked by its lifestyle manager...")] | ||
public void Disposable_singleton_as_dependency_of_non_disposable_transient_is_not_tracked() | ||
{ | ||
SimpleServiceDisposable.DisposedCount = 0; | ||
Container.Register(Component.For<HasCtorDependency>().LifeStyle.Transient, | ||
Component.For<ISimpleService>().ImplementedBy<SimpleServiceDisposable>()); | ||
|
||
var root = Container.Resolve<HasCtorDependency>(); | ||
|
||
Assert.IsFalse(Kernel.ReleasePolicy.HasTrack(root.Dependency)); | ||
} | ||
|
||
[Test] | ||
public void Disposable_singleton_as_dependency_of_non_disposable_transient_is_decommissionsed_with_container() | ||
{ | ||
SimpleServiceDisposable.DisposedCount = 0; | ||
Container.Register(Component.For<HasCtorDependency>().LifeStyle.Transient, | ||
Component.For<ISimpleService>().ImplementedBy<SimpleServiceDisposable>()); | ||
|
||
Container.Resolve<HasCtorDependency>(); | ||
CleanUp(); | ||
|
||
Assert.AreEqual(1, SimpleServiceDisposable.DisposedCount); | ||
; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters