Skip to content

Commit

Permalink
Merge pull request #127 from unitycontainer/release/5.11
Browse files Browse the repository at this point in the history
Release/5.11
  • Loading branch information
ENikS authored Dec 12, 2019
2 parents 2e9266f + a937e29 commit a0f65d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<VersionBase>5.11.2</VersionBase>
<VersionBase>5.11.3</VersionBase>
<TargetFrameworks>netstandard2.0;netstandard1.0;netcoreapp2.0;netcoreapp1.0;net47;net46;net45;net40</TargetFrameworks>
</PropertyGroup>

Expand Down
31 changes: 16 additions & 15 deletions src/Lifetime/Managers/ExternallyControlledLifetimeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Unity.Lifetime
/// A <see cref="LifetimeManager"/> that holds a weak reference to
/// it's managed instance.
/// </summary>
public class ExternallyControlledLifetimeManager : LifetimeManager,
public class ExternallyControlledLifetimeManager : SynchronizedLifetimeManager,
IInstanceLifetimeManager,
ITypeLifetimeManager,
IFactoryLifetimeManager
Expand All @@ -18,35 +18,36 @@ public class ExternallyControlledLifetimeManager : LifetimeManager,
#endregion


#region Overrides
#region SynchronizedLifetimeManager

/// <summary>
/// Retrieve a value from the backing store associated with this Lifetime policy.
/// </summary>
/// <param name="container">Instance of container requesting the value</param>
/// <returns>the object desired, or null if no such object is currently stored.</returns>
public override object GetValue(ILifetimeContainer container = null)
/// <inheritdoc/>
protected override object SynchronizedGetValue(ILifetimeContainer container = null)
{
if (null == _value) return NoValue;

var target = _value.Target;
if (_value.IsAlive) return target;
if (null != target) return target;

_value = null;

return NoValue;
}

/// <summary>
/// Stores the given value into backing store for retrieval later.
/// </summary>
/// <param name="container">Instance of container which owns the value</param>
/// <param name="newValue">The object being stored.</param>
public override void SetValue(object newValue, ILifetimeContainer container = null)
/// <inheritdoc/>
protected override void SynchronizedSetValue(object newValue, ILifetimeContainer container = null)
{
_value = new WeakReference(newValue);
}


/// <inheritdoc/>
public override void RemoveValue(ILifetimeContainer container = null) => _value = null;

#endregion


#region Overrides

protected override LifetimeManager OnCreateLifetimeManager()
{
return new ExternallyControlledLifetimeManager();
Expand Down
2 changes: 1 addition & 1 deletion src/Unity.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit a0f65d6

Please sign in to comment.