8000 Supporting .NET Framework 4.5.2 by FrankPfattheicher · Pull Request #45 · gautema/CQRSlite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Supporting .NET Framework 4.5.2 #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CQRSlite.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<description>A lightweight framework to help write CQRS and Eventsourcing applications in C#</description>
<copyright>Copyright 2017</copyright>
<dependencies>
<group targetFramework=".NETFramework4.6.1">
<group targetFramework=".NETFramework4.5.2">
</group>
<group targetFramework=".NETStandard1.3">
<dependency id="NETStandard.Library" version="1.6.1" />
Expand All @@ -36,7 +36,7 @@
<file src="Framework\CQRSlite\bin\Release\netstandard1.5\CQRSlite.dll" target="lib\netstandard1.5\CQRSlite.dll" />
<file src="Framework\CQRSlite\bin\Release\netstandard1.5\CQRSlite.pdb" target="lib\netstandard1.5\CQRSlite.pdb" />
<file src="Framework\CQRSlite\bin\Release\netstandard1.5\CQRSlite.deps.json" target="lib\netstandard1.5\CQRSlite.deps.json" />
<file src="Framework\CQRSlite\bin\Release\net461\CQRSlite.dll" target="lib\net461\CQRSlite.dll" />
<file src="Framework\CQRSlite\bin\Release\net461\CQRSlite.pdb" target="lib\net461\CQRSlite.pdb" />
<file src="Framework\CQRSlite\bin\Release\net452\CQRSlite.dll" target="lib\net452\CQRSlite.dll" />
<file src="Framework\CQRSlite\bin\Release\net452\CQRSlite.pdb" target="lib\net452\CQRSlite.pdb" />
</files>
</package>
3 changes: 2 additions & 1 deletion Framework/CQRSlite/Bus/InProcessBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public void RegisterHandler<T>(Func<T, CancellationToken, Task> handler) where T
public Task Publish<T>(T @event, CancellationToken cancellationToken = default(CancellationToken)) where T : class, IEvent
{
if (!_routes.TryGetValue(@event.GetType(), out var handlers))
return Task.CompletedTask;
return Task.FromResult(0);

return Task.WhenAll(handlers.Select(handler => handler(@event, cancellationToken)));
}
}
Expand Down
4 changes: 2 additions & 2 deletions Framework/CQRSlite/CQRSlite.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard1.5;net461</TargetFrameworks>
<TargetFrameworks>netstandard1.3;netstandard1.5;net452</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
Expand All @@ -18,7 +18,7 @@
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461' ">
<ItemGroup Condition="'$(TargetFramework)' == 'net452' ">
<Reference Include="System.Runtime.Caching" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
Expand Down
16 changes: 8 additions & 8 deletions Framework/CQRSlite/Cache/MemoryCache.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using CQRSlite.Domain;
#if NET461
#if NET452
using System.Runtime.Caching;
#else
using Microsoft.Extensions.Caching.Memory;
Expand All @@ -10,7 +10,7 @@ namespace CQRSlite.Cache
{
public class MemoryCache : ICache
{
#if NET461
#if NET452
private readonly System.Runtime.Caching.MemoryCache _cache;
private Func<CacheItemPolicy> _policyFactory;
#else
Expand All @@ -21,7 +21,7 @@ public class MemoryCache : ICache
public MemoryCache()
{

#if NET461
#if NET452
_cache = System.Runtime.Caching.MemoryCache.Default;
_policyFactory = () => new CacheItemPolicy {
SlidingExpiration = TimeSpan.FromMinutes(15)
Expand All @@ -38,7 +38,7 @@ public MemoryCache()

public bool IsTracked(Guid id)
{
#if NET461
#if NET452
return _cache.Contains(id.ToString());
#else
return _cache.TryGetValue(id, out var o) && o != null;
Expand All @@ -47,7 +47,7 @@ public bool IsTracked(Guid id)

public void Set(Guid id, AggregateRoot aggregate)
{
#if NET461
#if NET452
_cache.Add(id.ToString(), aggregate, _policyFactory.Invoke());
#else
_cache.Set(id, aggregate, _cacheOptions);
Expand All @@ -56,7 +56,7 @@ public void Set(Guid id, AggregateRoot aggregate)

public AggregateRoot Get(Guid id)
{
#if NET461
#if NET452
return (AggregateRoot)_cache.Get(id.ToString());
#else
return (AggregateRoot) _cache.Get(id);
Expand All @@ -65,7 +65,7 @@ public AggregateRoot Get(Guid id)

public void Remove(Guid id)
{
#if NET461
#if NET452
_cache.Remove(id.ToString());
#else
_cache.Remove(id);
Expand All @@ -74,7 +74,7 @@ public void Remove(Guid id)

public void RegisterEvictionCallback(Action<Guid> action)
{
#if NET461
#if NET452
_policyFactory = () => new CacheItemPolicy
{
SlidingExpiration = TimeSpan.FromMinutes(15),
Expand Down
2 changes: 1 addition & 1 deletion Framework/CQRSlite/Domain/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Session(IRepository repository)
{
throw new ConcurrencyException(aggregate.Id);
}
return Task.CompletedTask;
return Task.FromResult(0);
}

public async Task<T> Get<T>(Guid id, int? expectedVersion = null, CancellationToken cancellationToken = default(CancellationToken)) where T : AggregateRoot
Expand Down
2 changes: 1 addition & 1 deletion Framework/CQRSlite/Snapshots/SnapshotRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private async Task<int> TryRestoreAggregateFromSnapshot<T>(Guid id, T aggregate,
private Task TryMakeSnapshot(AggregateRoot aggregate)
{
if (!_snapshotStrategy.ShouldMakeSnapShot(aggregate))
return Task.CompletedTask;
return Task.FromResult(0);

var snapshot = aggregate.AsDynamic().GetSnapshot();
snapshot.Version = aggregate.Version + aggregate.GetUncommittedChanges().Length;
Expand Down
0