Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #24 from AppCoreNet/dev
Browse files Browse the repository at this point in the history
Release v0.4.0
  • Loading branch information
prochnowc authored Nov 5, 2022
2 parents 85b8451 + 505ed8f commit 631cd0a
Show file tree
Hide file tree
Showing 176 changed files with 5,011 additions and 5,091 deletions.
22 changes: 22 additions & 0 deletions AppCore.EventModel.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppCore.EventModel.EFCore.M
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppCore.EventModel.EFCore.SqlServer.Tests", "test\AppCore.EventModel.EFCore.SqlServer.Tests\AppCore.EventModel.EFCore.SqlServer.Tests.csproj", "{09217A6E-AA2B-4D8E-A033-A5919EED5599}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A9EB5988-A0CD-4695-9BA9-DB9B9436A244}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{75F08520-67A2-4479-A584-00BF4B7DA4A8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -112,4 +116,22 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1D612036-7B49-4BA4-9DE0-86F1FADC6FB3}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{18153F6D-A037-40B7-B5D4-5383255BD89D} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{609D2506-8909-4814-929F-59BC262E5913} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{97932B36-F306-4918-BC81-5A237BBAEDD0} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{D03851E0-52F8-468E-98B0-EBC06D2BE120} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{0EBF460A-3075-43CF-B04F-943196FA3944} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{A5C60F54-23BB-4E07-92E3-B57AC8EA709E} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{30A20DAF-1CA8-4538-9489-A0238A583BC5} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{CD1E2BC7-735F-4333-88FC-CFBD0D311F6C} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{6BF073F8-70AF-47AE-9AF9-782E35404A2E} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{69F56F13-DA52-45A8-A596-DEC19C2774C4} = {A9EB5988-A0CD-4695-9BA9-DB9B9436A244}
{A3441E49-0F2E-48D8-AAD8-E7310B1E79A2} = {75F08520-67A2-4479-A584-00BF4B7DA4A8}
{2E9C7C0F-7A30-4EA0-8612-A4B33E1DC2A7} = {75F08520-67A2-4479-A584-00BF4B7DA4A8}
{09217A6E-AA2B-4D8E-A033-A5919EED5599} = {75F08520-67A2-4479-A584-00BF4B7DA4A8}
{3914B193-0FBA-425A-921C-9402D44CFBC2} = {75F08520-67A2-4479-A584-00BF4B7DA4A8}
{C6E2D0D2-1908-4F20-831C-46327C4B2AA5} = {75F08520-67A2-4479-A584-00BF4B7DA4A8}
{E0698B78-612C-44EB-81D4-E2BA9EDCB933} = {75F08520-67A2-4479-A584-00BF4B7DA4A8}
EndGlobalSection
EndGlobal
5 changes: 3 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
<Product>AppCore .NET event model</Product>
<Copyright>Copyright (c) 2018-2020 the AppCore .NET project</Copyright>
<Version>1.0.0</Version>
<PackageLicenseUrl>https://github.com/AppCoreNet/Events/blob/dev/LICENSE</PackageLicenseUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/AppCoreNet/Events</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);NU5105</NoWarn>
<Nullable>enable</Nullable>
<!--
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode Condition="'$(CI)' == 'true'">true</RestoreLockedMode>
-->
<DefineConstants>$(DefineConstants);ENABLE_NULLABLE</DefineConstants>
</PropertyGroup>

<Import Project="./build/shared/dotnet/common.props" />
Expand Down
9 changes: 4 additions & 5 deletions build/dependency-versions.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project>
<PropertyGroup>
<AppCore_Shared_Version>0.3.0</AppCore_Shared_Version>
<AppCore_DI_Version>0.3.0</AppCore_DI_Version>
<AppCore_Data_Version>0.3.0</AppCore_Data_Version>
<AppCore_Hosting_Version>0.3.0</AppCore_Hosting_Version>
<Microsoft_Extensions_Version>[2.1.0,7.0.0)</Microsoft_Extensions_Version>
<AppCore_Shared_Version>0.4.3</AppCore_Shared_Version>
<AppCore_Extensions_Version>0.4.0</AppCore_Extensions_Version>
<AppCore_Data_Version>0.4.0</AppCore_Data_Version>
<Microsoft_Extensions_Version>3.1.28</Microsoft_Extensions_Version>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions build/shared/azure-pipelines/build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ parameters:
testFilter: ''

steps:
- pwsh: ./build.ps1 --configuration='${{ parameters.configuration }}'
- pwsh: ./build.ps1 --configuration "${{ parameters.configuration }}"
displayName: Build
- pwsh: ./build.ps1 --target=Test --skip-target='Build' --configuration='${{ parameters.configuration }}' --test-filter='${{ parameters.testFilter }}' --artifactsDir='$(Build.ArtifactStagingDirectory)'
- pwsh: ./build.ps1 --target "Test" --skip-target "Build" --configuration "${{ parameters.configuration }}" --test-filter "${{ parameters.testFilter }}" --artifactsDir "$(Build.ArtifactStagingDirectory)"
displayName: Run Tests
- task: PublishTestResults@2
displayName: Publish Test Results
Expand Down
13 changes: 7 additions & 6 deletions build/shared/azure-pipelines/install-steps.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
steps:
- task: UseDotNet@2
displayName: 'Install .NET Core SDK 2.1'
inputs:
version: '2.1.x'

- task: UseDotNet@2
displayName: 'Install .NET Core SDK 3.1'
inputs:
version: '3.1.x'
- task: UseDotNet@2
displayName: 'Install .NET Core SDK 5'
displayName: 'Install .NET SDK 5'
inputs:
version: '5.x'
- task: UseDotNet@2
displayName: 'Install .NET SDK 6'
inputs:
version: '5.0.x'
version: '6.x'
- task: NuGetToolInstaller@1
displayName: 'Install NuGet 5.4'
inputs:
Expand Down
2 changes: 1 addition & 1 deletion build/shared/azure-pipelines/publish-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
configuration: 'Debug'

steps:
- pwsh: ./build.ps1 --target=Publish --configuration='${{ parameters.configuration }}' --artifactsDir='$(Build.ArtifactStagingDirectory)'
- pwsh: ./build.ps1 --target "Publish" --configuration "${{ parameters.configuration }}" --artifactsDir "$(Build.ArtifactStagingDirectory)"
displayName: Publish
- task: NuGetCommand@2
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<RootNamespace>AppCore.EventModel</RootNamespace>
<Description>Provides AppCore .NET abstractions for event model.</Description>
</PropertyGroup>
Expand All @@ -13,7 +13,6 @@
<PackageReference Include="AppCore.TypeHelpers.Sources" Version="$(AppCore_Shared_Version)">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="AppCore.DependencyInjection.Abstractions" Version="$(AppCore_DI_Version)" />
</ItemGroup>

</Project>
17 changes: 8 additions & 9 deletions src/AppCore.EventModel.Abstractions/CancelableAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

using System;

namespace AppCore.EventModel
namespace AppCore.EventModel;

/// <summary>
/// Enables cancellation for the event type.
/// </summary>
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface)]
public class CancelableAttribute : Attribute
{
/// <summary>
/// Enables cancellation for the event type.
/// </summary>
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface)]
public class CancelableAttribute : Attribute
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,32 @@
using AppCore.Diagnostics;
using AppCore.EventModel.Pipeline;

namespace AppCore.EventModel
namespace AppCore.EventModel;

/// <summary>
/// Provides extension methods for the <see cref="IEventContext"/> type.
/// </summary>
public static class CancelableEventContextExtensions
{
/// <summary>
/// Provides extension methods for the <see cref="IEventContext"/> type.
/// Gets a value indicating whether the event is cancelable.
/// </summary>
public static class CancelableEventContextExtensions
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <returns><c>true</c> if the event can be canceled; <c>false</c> otherwise.</returns>
public static bool IsCancelable(this IEventContext context)
{
/// <summary>
/// Gets a value indicating whether the event is cancelable.
/// </summary>
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <returns><c>true</c> if the event can be canceled; <c>false</c> otherwise.</returns>
public static bool IsCancelable(this IEventContext context)
{
Ensure.Arg.NotNull(context, nameof(context));
return context.HasFeature<ICancelableEventFeature>();
}
Ensure.Arg.NotNull(context);
return context.HasFeature<ICancelableEventFeature>();
}

/// <summary>
/// Cancels the event.
/// </summary>
/// <param name="context">The <see cref="IEventContext"/>.</param>
public static void Cancel(this IEventContext context)
{
Ensure.Arg.NotNull(context, nameof(context));
var feature = context.GetFeature<ICancelableEventFeature>();
feature.Cancel();
}
/// <summary>
/// Cancels the event.
/// </summary>
/// <param name="context">The <see cref="IEventContext"/>.</param>
public static void Cancel(this IEventContext context)
{
Ensure.Arg.NotNull(context);
var feature = context.GetFeature<ICancelableEventFeature>();
feature.Cancel();
}
}
127 changes: 63 additions & 64 deletions src/AppCore.EventModel.Abstractions/EventContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,80 @@
using System;
using AppCore.Diagnostics;

namespace AppCore.EventModel
namespace AppCore.EventModel;

/// <summary>
/// Provides extension methods for the <see cref="IEventContext"/>.
/// </summary>
public static class EventContextExtensions
{
/// <summary>
/// Provides extension methods for the <see cref="IEventContext"/>.
/// Adds a feature to the <see cref="IEventContext"/>.
/// </summary>
public static class EventContextExtensions
/// <typeparam name="T">The type of the feature.</typeparam>
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <param name="feature">The feature that should be added.</param>
/// <exception cref="InvalidOperationException">The event context feature is already registered.</exception>
public static void AddFeature<T>(this IEventContext context, T feature)
{
/// <summary>
/// Adds a feature to the <see cref="IEventContext"/>.
/// </summary>
/// <typeparam name="T">The type of the feature.</typeparam>
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <param name="feature">The feature that should be added.</param>
/// <exception cref="InvalidOperationException">The event context feature is already registered.</exception>
public static void AddFeature<T>(this IEventContext context, T feature)
{
Ensure.Arg.NotNull(context, nameof(context));
Ensure.Arg.NotNull(feature, nameof(feature));
Ensure.Arg.NotNull(context);
Ensure.Arg.NotNull(feature);

try
{
context.Features.Add(typeof(T), feature);
}
catch (ArgumentException)
{
throw new InvalidOperationException($"Event context feature {typeof(T).GetDisplayName()} already registered.");
}
try
{
context.Features.Add(typeof(T), feature);
}

/// <summary>
/// Gets the feature with the specified type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type of the feature.</typeparam>
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <param name="feature">The feature.</param>
/// <returns><c>true</c> if the feature was found; <c>false</c> otherwise.</returns>
public static bool TryGetFeature<T>(this IEventContext context, out T feature)
catch (ArgumentException)
{
Ensure.Arg.NotNull(context, nameof(context));
throw new InvalidOperationException($"Event context feature {typeof(T).GetDisplayName()} already registered.");
}
}

if (context.Features.TryGetValue(typeof(T), out object tmp))
{
feature = (T) tmp;
return true;
}
/// <summary>
/// Gets the feature with the specified type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type of the feature.</typeparam>
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <param name="feature">The feature.</param>
/// <returns><c>true</c> if the feature was found; <c>false</c> otherwise.</returns>
public static bool TryGetFeature<T>(this IEventContext context, out T? feature)
{
Ensure.Arg.NotNull(context);

feature = default;
return false;
if (context.Features.TryGetValue(typeof(T), out object? tmp))
{
feature = (T) tmp;
return true;
}

/// <summary>
/// Gets the feature with the specified type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type of the feature.</typeparam>
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <returns>The feature.</returns>
/// <exception cref="InvalidOperationException">The event context feature is not available.</exception>
public static T GetFeature<T>(this IEventContext context)
{
if (!TryGetFeature(context, out T feature))
throw new InvalidOperationException($"Event context feature {typeof(T).GetDisplayName()} is not available.");
feature = default;
return false;
}

return feature;
}
/// <summary>
/// Gets the feature with the specified type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type of the feature.</typeparam>
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <returns>The feature.</returns>
/// <exception cref="InvalidOperationException">The event context feature is not available.</exception>
public static T GetFeature<T>(this IEventContext context)
{
if (!TryGetFeature(context, out T? feature))
throw new InvalidOperationException($"Event context feature {typeof(T).GetDisplayName()} is not available.");

/// <summary>
/// Gets a value indicating whether a feature is available.
/// </summary>
/// <typeparam name="T">The type of the feature.</typeparam>
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <returns><c>true</c> if the feature is available; <c>false</c> otherwise.</returns>
public static bool HasFeature<T>(this IEventContext context)
{
Ensure.Arg.NotNull(context, nameof(context));
return context.Features.ContainsKey(typeof(T));
}
return feature!;
}

/// <summary>
/// Gets a value indicating whether a feature is available.
/// </summary>
/// <typeparam name="T">The type of the feature.</typeparam>
/// <param name="context">The <see cref="IEventContext"/>.</param>
/// <returns><c>true</c> if the feature is available; <c>false</c> otherwise.</returns>
public static bool HasFeature<T>(this IEventContext context)
{
Ensure.Arg.NotNull(context);
return context.Features.ContainsKey(typeof(T));
}
}
}
Loading

0 comments on commit 631cd0a

Please sign in to comment.