Skip to content

Commit e3ab154

Browse files
Now supporting .Net Standard v1.0 - v2.1
1 parent fc04449 commit e3ab154

File tree

6 files changed

+53
-27
lines changed

6 files changed

+53
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![CD](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading/actions/workflows/CD.yml/badge.svg)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading/actions/workflows/CD.yml)
44
[![Nuget](https://img.shields.io/nuget/v/ThunderDesign.Net-PCL.Threading)](https://www.nuget.org/packages/ThunderDesign.Net-PCL.Threading)
55
[![License](https://img.shields.io/github/license/ThunderDesign/ThunderDesign.Net-PCL.Threading)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading/blob/main/LICENSE)
6-
[![Net](https://img.shields.io/badge/.net%20standard-2.0-blue)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading/blob/main/README.md)
6+
[![Net](https://img.shields.io/badge/.net%20standard-v1.0%20--%20v2.1-blue)](https://github.com/ThunderDesign/ThunderDesign.Net-PCL.Threading/blob/main/README.md)
77

88
A combination of generic Thread-Safe objects for .Net development.
99

src/ThunderDesign.Net-PCL.Threading/Collections/DictionaryThreadSafe.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
using System;
22
using System.Collections.Generic;
3+
#if NETSTANDARD2_0 || NETSTANDARD2_1
34
using System.Runtime.Serialization;
5+
#endif
46
using System.Threading;
57
using ThunderDesign.Net.Threading.Interfaces;
68

79
namespace ThunderDesign.Net.Threading.Collections
810
{
911
public class DictionaryThreadSafe<TKey, TValue> : Dictionary<TKey, TValue>, IDictionaryThreadSafe<TKey, TValue>
1012
{
11-
#region constructors
13+
#region constructors
1214
public DictionaryThreadSafe() : base() { }
1315
public DictionaryThreadSafe(int capacity) : base(capacity) { }
1416
public DictionaryThreadSafe(IEqualityComparer<TKey> comparer) : base(comparer) { }
1517
public DictionaryThreadSafe(IDictionary<TKey, TValue> dictionary) : base(dictionary) { }
1618
public DictionaryThreadSafe(int capacity, IEqualityComparer<TKey> comparer) : base(capacity, comparer) { }
1719
public DictionaryThreadSafe(IDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey> comparer) : base(dictionary, comparer) { }
18-
#endregion
20+
#endregion
1921

20-
#region properties
22+
#region properties
2123
public bool IsSynchronized
2224
{
2325
get { return true; }
@@ -114,9 +116,9 @@ public bool IsSynchronized
114116
}
115117
}
116118
}
117-
#endregion
119+
#endregion
118120

119-
#region methods
121+
#region methods
120122
public new virtual void Add(TKey key, TValue value)
121123
{
122124
_ReaderWriterLockSlim.EnterWriteLock();
@@ -182,6 +184,7 @@ public bool IsSynchronized
182184
}
183185
}
184186

187+
#if NETSTANDARD2_0 || NETSTANDARD2_1
185188
[System.Security.SecurityCritical] // auto-generated_required
186189
public override void GetObjectData(SerializationInfo info, StreamingContext context)
187190
{
@@ -208,7 +211,7 @@ public override void OnDeserialization(Object sender)
208211
_ReaderWriterLockSlim.ExitReadLock();
209212
}
210213
}
211-
214+
#endif
212215
public new virtual bool Remove(TKey key)
213216
{
214217
bool result = false;
@@ -236,10 +239,10 @@ public override void OnDeserialization(Object sender)
236239
_ReaderWriterLockSlim.ExitReadLock();
237240
}
238241
}
239-
#endregion
242+
#endregion
240243

241-
#region variables
244+
#region variables
242245
protected static readonly ReaderWriterLockSlim _ReaderWriterLockSlim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
243-
#endregion
246+
#endregion
244247
}
245248
}

src/ThunderDesign.Net-PCL.Threading/Collections/ListThreadSafe.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public bool IsSynchronized
122122
}
123123
}
124124

125+
#if NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6 || NETSTANDARD2_0 || NETSTANDARD2_1
125126
public new ReadOnlyCollection<T> AsReadOnly()
126127
{
127128
_ReaderWriterLockSlim.EnterReadLock();
@@ -134,6 +135,7 @@ public bool IsSynchronized
134135
_ReaderWriterLockSlim.ExitReadLock();
135136
}
136137
}
138+
#endif
137139

138140
public new int BinarySearch(T item)
139141
{
@@ -200,6 +202,7 @@ public bool IsSynchronized
200202
}
201203
}
202204

205+
#if NETSTANDARD2_0 || NETSTANDARD2_1
203206
public new List<TOutput> ConvertAll<TOutput>(Converter<T, TOutput> converter)
204207
{
205208
_ReaderWriterLockSlim.EnterReadLock();
@@ -212,6 +215,7 @@ public bool IsSynchronized
212215
_ReaderWriterLockSlim.ExitReadLock();
213216
}
214217
}
218+
#endif
215219

216220
public new void CopyTo(int index, T[] array, int arrayIndex, int count)
217221
{
@@ -382,6 +386,7 @@ public bool IsSynchronized
382386
}
383387
}
384388

389+
#if NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6 || NETSTANDARD2_0 || NETSTANDARD2_1
385390
public new void ForEach(Action<T> action)
386391
{
387392
_ReaderWriterLockSlim.EnterReadLock();
@@ -394,6 +399,7 @@ public bool IsSynchronized
394399
_ReaderWriterLockSlim.ExitReadLock();
395400
}
396401
}
402+
#endif
397403

398404
public new Enumerator GetEnumerator()
399405
{
@@ -693,10 +699,10 @@ public bool IsSynchronized
693699
_ReaderWriterLockSlim.ExitWriteLock();
694700
}
695701
}
696-
#endregion
702+
#endregion
697703

698-
#region variables
704+
#region variables
699705
protected static readonly ReaderWriterLockSlim _ReaderWriterLockSlim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
700-
#endregion
706+
#endregion
701707
}
702708
}

src/ThunderDesign.Net-PCL.Threading/Collections/SortedListThreadSafe.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace ThunderDesign.Net_PCL.Threading.Collections
66
{
7+
#if NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6 || NETSTANDARD2_0 || NETSTANDARD2_1
78
public class SortedListThreadSafe<TKey, TValue> : SortedList<TKey, TValue>, ISortedListThreadSafe<TKey, TValue>
89
{
9-
#region constructors
10+
#region constructors
1011
public SortedListThreadSafe() : base() { }
1112

1213
public SortedListThreadSafe(IComparer<TKey> comparer) : base(comparer) { }
@@ -18,9 +19,9 @@ public SortedListThreadSafe(IDictionary<TKey, TValue> dictionary, IComparer<TKey
1819
public SortedListThreadSafe(int capacity) : base(capacity) { }
1920

2021
public SortedListThreadSafe(int capacity, IComparer<TKey> comparer) : base(capacity, comparer) { }
21-
#endregion
22+
#endregion
2223

23-
#region properties
24+
#region properties
2425
public bool IsSynchronized
2526
{
2627
get { return true; }
@@ -145,9 +146,9 @@ public bool IsSynchronized
145146
}
146147
}
147148
}
148-
#endregion
149+
#endregion
149150

150-
#region methods
151+
#region methods
151152
public new void Add(TKey key, TValue value)
152153
{
153154
_ReaderWriterLockSlim.EnterWriteLock();
@@ -291,10 +292,11 @@ public bool IsSynchronized
291292
_ReaderWriterLockSlim.ExitReadLock();
292293
}
293294
}
294-
#endregion
295+
#endregion
295296

296-
#region variables
297+
#region variables
297298
protected static readonly ReaderWriterLockSlim _ReaderWriterLockSlim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
298-
#endregion
299+
#endregion
299300
}
301+
#endif
300302
}

src/ThunderDesign.Net-PCL.Threading/Interfaces/IDictionaryThreadSafe.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
using System.Collections;
22
using System.Collections.Generic;
3+
#if NETSTANDARD2_0 || NETSTANDARD2_1
34
using System.Runtime.Serialization;
4-
5+
#endif
56
namespace ThunderDesign.Net.Threading.Interfaces
67
{
8+
#if NETSTANDARD2_0 || NETSTANDARD2_1
79
public interface IDictionaryThreadSafe : IDictionary, IDeserializationCallback, ISerializable
10+
#else
11+
public interface IDictionaryThreadSafe : IDictionary
12+
#endif
813
{
914
}
1015

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<RootNamespace>ThunderDesign.Net_PCL.Threading</RootNamespace>
6-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard1.0;netstandard1.3;netstandard2.0;net461</TargetFrameworks>
5+
<RootNamespace>ThunderDesign.Net_PCL.Threading</RootNamespace>
6+
<PackageReadmeFile>README.md</PackageReadmeFile>
7+
</PropertyGroup>
8+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
9+
<DefineConstants>NETSTANDARD1_4</DefineConstants>
10+
</PropertyGroup>
11+
<ItemGroup>
12+
<None Include="..\..\README.md">
13+
<Pack>True</Pack>
14+
<PackagePath>\</PackagePath>
15+
</None>
16+
</ItemGroup>
717

818
</Project>

0 commit comments

Comments
 (0)