Skip to content
This repository has been archived by the owner on Feb 6, 2021. It is now read-only.

Commit

Permalink
Replaced ObjectDataCollection with a ConcurrentDictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
christophano committed May 24, 2018
1 parent cb18ba4 commit 26c5c03
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@
<Compile Include="..\Effort.Extra\ObjectData.cs">
<Link>ObjectData.cs</Link>
</Compile>
<Compile Include="..\Effort.Extra\ObjectDataCollection.cs">
<Link>ObjectDataCollection.cs</Link>
</Compile>
<Compile Include="..\Effort.Extra\ObjectDataLoader.cs">
<Link>ObjectDataLoader.cs</Link>
</Compile>
Expand Down
3 changes: 0 additions & 3 deletions Effort.Extra.EF6.Tests/Effort.Extra.EF6.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@
<Compile Include="..\Effort.Extra.Tests\ObjectData.cs">
<Link>ObjectData.cs</Link>
</Compile>
<Compile Include="..\Effort.Extra.Tests\ObjectDataCollection.cs">
<Link>ObjectDataCollection.cs</Link>
</Compile>
<Compile Include="..\Effort.Extra.Tests\ObjectDataLoader.cs">
<Link>ObjectDataLoader.cs</Link>
</Compile>
Expand Down
3 changes: 0 additions & 3 deletions Effort.Extra.EF6/Effort.Extra.EF6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@
<Compile Include="..\Effort.Extra\ObjectData.cs">
<Link>ObjectData.cs</Link>
</Compile>
<Compile Include="..\Effort.Extra\ObjectDataCollection.cs">
<Link>ObjectDataCollection.cs</Link>
</Compile>
<Compile Include="..\Effort.Extra\ObjectDataLoader.cs">
<Link>ObjectDataLoader.cs</Link>
</Compile>
Expand Down
3 changes: 0 additions & 3 deletions Effort.Extra.StrongName/Effort.Extra.StrongName.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@
<Compile Include="..\Effort.Extra\ObjectData.cs">
<Link>ObjectData.cs</Link>
</Compile>
<Compile Include="..\Effort.Extra\ObjectDataCollection.cs">
<Link>ObjectDataCollection.cs</Link>
</Compile>
<Compile Include="..\Effort.Extra\ObjectDataLoader.cs">
<Link>ObjectDataLoader.cs</Link>
</Compile>
Expand Down
1 change: 0 additions & 1 deletion Effort.Extra.Tests/Effort.Extra.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
<Compile Include="Builder.cs" />
<Compile Include="PersonWithAttribute.cs" />
<Compile Include="ObjectData.cs" />
<Compile Include="ObjectDataCollection.cs" />
<Compile Include="ObjectDataLoader.cs" />
<Compile Include="ObjectDataLoaderFactory.cs" />
<Compile Include="ObjectTableDataLoader.cs" />
Expand Down
156 changes: 0 additions & 156 deletions Effort.Extra.Tests/ObjectDataCollection.cs

This file was deleted.

1 change: 0 additions & 1 deletion Effort.Extra/Effort.Extra.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="ObjectData.cs" />
<Compile Include="ObjectDataCollection.cs" />
<Compile Include="ObjectDataLoader.cs" />
<Compile Include="ObjectDataLoaderFactory.cs" />
<Compile Include="ObjectDataTable`1.cs" />
Expand Down
56 changes: 0 additions & 56 deletions Effort.Extra/ObjectDataCollection.cs

This file was deleted.

11 changes: 5 additions & 6 deletions Effort.Extra/ObjectDataLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Effort.Extra
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using Effort.DataLoaders;

Expand All @@ -10,7 +11,7 @@ namespace Effort.Extra
/// </summary>
public class ObjectDataLoader : IDataLoader
{
private static readonly ObjectDataCollection DataCollection = new ObjectDataCollection();
private static readonly ConcurrentDictionary<Guid, ObjectData> DataCollection = new ConcurrentDictionary<Guid, ObjectData>();

/// <summary>
/// Initializes a new instance of the <see cref="ObjectDataLoader"/> class.
Expand All @@ -25,7 +26,7 @@ public ObjectDataLoader(ObjectData data)
{
if (data == null) throw new ArgumentNullException(nameof(data));
Argument = data.Identifier.ToString();
DataCollection.AddOrUpdate(data);
DataCollection.AddOrUpdate(data.Identifier, data, (key, value) => data);
}

/// <summary>
Expand All @@ -50,11 +51,9 @@ public ObjectDataLoader(ObjectData data)
/// </exception>
public ITableDataLoaderFactory CreateTableDataLoaderFactory()
{
Guid id;
if (Guid.TryParse(Argument, out id))
if (Guid.TryParse(Argument, out var id))
{
ObjectData data;
if (DataCollection.TryGetValue(id, out data))
if (DataCollection.TryGetValue(id, out var data))
{
return new ObjectDataLoaderFactory(data);
}
Expand Down

0 comments on commit 26c5c03

Please sign in to comment.