Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Commit

Permalink
removed dep on thrower
Browse files Browse the repository at this point in the history
  • Loading branch information
pomma89 committed Jun 23, 2017
1 parent 327c7b3 commit 5a1af7e
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 47 deletions.
19 changes: 12 additions & 7 deletions src/CodeProject.ObjectPool/CodeProject.ObjectPool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,35 @@
<None Remove="doc\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Thrower" Version="4.1.3" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' ">
<DefineConstants>$(DefineConstants);NETSTD10;LIBLOG_PORTABLE</DefineConstants>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<DefineConstants>$(DefineConstants);NETSTD13;LIBLOG_PORTABLE</DefineConstants>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net35' ">
<DefineConstants>$(DefineConstants);NET35</DefineConstants>
<DefineConstants>$(DefineConstants);NET35;HAS_SERIALIZABLE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net35' ">
<Reference Include="System" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<DefineConstants>$(DefineConstants);NET40</DefineConstants>
<DefineConstants>$(DefineConstants);NET40;HAS_SERIALIZABLE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
Expand All @@ -65,7 +70,7 @@
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<DefineConstants>$(DefineConstants);NET45</DefineConstants>
<DefineConstants>$(DefineConstants);NET45;HAS_SERIALIZABLE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
Expand Down
5 changes: 2 additions & 3 deletions src/CodeProject.ObjectPool/ParameterizedObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

using CodeProject.ObjectPool.Core;
using PommaLabs.Thrower;
using System;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -69,7 +68,7 @@ public int MaximumPoolSize
set
{
// Preconditions
Raise.ArgumentOutOfRangeException.If(value < 1, nameof(value), ErrorMessages.NegativeOrZeroMaximumPoolSize);
if (value < 1) throw new ArgumentOutOfRangeException(nameof(value), ErrorMessages.NegativeOrZeroMaximumPoolSize);

_maximumPoolSize = value;
}
Expand Down Expand Up @@ -123,7 +122,7 @@ public ParameterizedObjectPool(Func<TKey, TValue> factoryMethod)
public ParameterizedObjectPool(int maximumPoolSize, Func<TKey, TValue> factoryMethod)
{
// Preconditions
Raise.ArgumentOutOfRangeException.If(maximumPoolSize < 1, nameof(maximumPoolSize), ErrorMessages.NegativeOrZeroMaximumPoolSize);
if (maximumPoolSize < 1) throw new ArgumentOutOfRangeException(nameof(maximumPoolSize), ErrorMessages.NegativeOrZeroMaximumPoolSize);

// Assigning properties
Diagnostics = new ObjectPoolDiagnostics();
Expand Down
67 changes: 37 additions & 30 deletions src/CodeProject.ObjectPool/PooledObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
*/

using CodeProject.ObjectPool.Core;
using PommaLabs.Thrower.Goodies;
using System;
using System.Collections.Generic;

#if !NET35

using PommaLabs.Thrower.Logging;
using CodeProject.ObjectPool.Logging;

#endif

Expand All @@ -24,8 +23,11 @@ namespace CodeProject.ObjectPool
/// <summary>
/// PooledObject base class.
/// </summary>
#if HAS_SERIALIZABLE
[Serializable]
public abstract class PooledObject : EquatableObject<PooledObject>, IDisposable
#endif

public abstract class PooledObject : IDisposable, IEquatable<PooledObject>
{
#region Logging

Expand Down Expand Up @@ -190,34 +192,39 @@ private void HandleReAddingToPool(bool reRegisterForFinalization)

#region Formatting and equality

/// <summary>
/// Returns all property (or field) values, along with their names, so that they can be
/// used to produce a meaningful <see cref="object.ToString"/>.
/// </summary>
/// <returns>
/// All property (or field) values, along with their names, so that they can be used to
/// produce a meaningful <see cref="object.ToString"/>.
/// </returns>
protected override IEnumerable<KeyValuePair<string, object>> GetFormattingMembers()
{
yield return new KeyValuePair<string, object>(nameof(PooledObjectInfo.Id), PooledObjectInfo.Id);
if (PooledObjectInfo.Payload != null)
{
yield return new KeyValuePair<string, object>(nameof(PooledObjectInfo.Payload), PooledObjectInfo.Payload);
}
}

/// <summary>
/// Returns all property (or field) values that should be used inside
/// <see cref="IEquatable{T}.Equals(T)"/> or <see cref="object.GetHashCode"/>.
/// </summary>
/// <returns>
/// All property (or field) values that should be used inside
/// <see cref="IEquatable{T}.Equals(T)"/> or <see cref="object.GetHashCode"/>.
/// </returns>
protected override IEnumerable<object> GetIdentifyingMembers()
///// <summary>
///// Returns all property (or field) values, along with their names, so that they can be
///// used to produce a meaningful <see cref="object.ToString"/>.
///// </summary>
///// <returns>
///// All property (or field) values, along with their names, so that they can be used to
///// produce a meaningful <see cref="object.ToString"/>.
///// </returns>
//protected override IEnumerable<KeyValuePair<string, object>> GetFormattingMembers()
//{
// yield return new KeyValuePair<string, object>(nameof(PooledObjectInfo.Id), PooledObjectInfo.Id);
// if (PooledObjectInfo.Payload != null)
// {
// yield return new KeyValuePair<string, object>(nameof(PooledObjectInfo.Payload), PooledObjectInfo.Payload);
// }
//}

///// <summary>
///// Returns all property (or field) values that should be used inside
///// <see cref="IEquatable{T}.Equals(T)"/> or <see cref="object.GetHashCode"/>.
///// </summary>
///// <returns>
///// All property (or field) values that should be used inside
///// <see cref="IEquatable{T}.Equals(T)"/> or <see cref="object.GetHashCode"/>.
///// </returns>
//protected override IEnumerable<object> GetIdentifyingMembers()
//{
// yield return PooledObjectInfo.Id;
//}

public bool Equals(PooledObject other)
{
yield return PooledObjectInfo.Id;
throw new NotImplementedException();
}

#endregion Formatting and equality
Expand Down
9 changes: 4 additions & 5 deletions src/CodeProject.ObjectPool/PooledObjectWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
*/

using CodeProject.ObjectPool.Core;
using PommaLabs.Thrower;
using System;

namespace CodeProject.ObjectPool
{
/// <summary>
/// PooledObject wrapper, for classes which cannot inherit from that class.
/// </summary>
#if HAS_SERIALIZABLE
[Serializable]
#endif

public sealed class PooledObjectWrapper<T> : PooledObject where T : class
{
/// <summary>
Expand All @@ -27,10 +29,7 @@ public sealed class PooledObjectWrapper<T> : PooledObject where T : class
/// <exception cref="ArgumentNullException">Given resource is null.</exception>
public PooledObjectWrapper(T resource)
{
// Preconditions
Raise.ArgumentNullException.IfIsNull(resource, nameof(resource), ErrorMessages.NullResource);

InternalResource = resource;
InternalResource = resource ?? throw new ArgumentNullException(nameof(resource), ErrorMessages.NullResource);

base.OnReleaseResources += () => OnReleaseResources?.Invoke(InternalResource);
base.OnResetState += () => OnResetState?.Invoke(InternalResource);
Expand Down
3 changes: 1 addition & 2 deletions src/CodeProject.ObjectPool/TimedObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#if !NETSTD10

using CodeProject.ObjectPool.Core;
using PommaLabs.Thrower;
using System;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -109,7 +108,7 @@ public TimedObjectPool(Func<T> factoryMethod, TimeSpan timeout)
public TimedObjectPool(int maximumPoolSize, Func<T> factoryMethod, TimeSpan timeout) : base(maximumPoolSize, factoryMethod)
{
// Preconditions
Raise.ArgumentOutOfRangeException.IfIsLessOrEqual(timeout, TimeSpan.Zero, nameof(timeout), ErrorMessages.NegativeOrZeroTimeout);
if (timeout <= TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(timeout), ErrorMessages.NegativeOrZeroTimeout);

// Assigning properties.
Timeout = timeout;
Expand Down

0 comments on commit 5a1af7e

Please sign in to comment.