-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added common extensions. * Added the validation extension. * Added decorators and named services. * Added caching and data management. * Added localization. * Fixed the package creation. * Added HTTP and OData client. * Added OData client. * Added some documentation.
- Loading branch information
Showing
192 changed files
with
8,257 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<LangVersion>latest</LangVersion> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<Company>Fluxera Software Development GmbH</Company> | ||
<Copyright>Copyright © 2014-2021 Fluxera Software Development GmbH. All rights reserved.</Copyright> | ||
<Product>Fluxera Software Foundation</Product> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<Version>6.0.0</Version> | ||
<AssemblyVersion>6.0.0</AssemblyVersion> | ||
<FileVersion>6.0.0</FileVersion> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<Authors>Matthias Gernand</Authors> | ||
<RepositoryUrl>https://github.com/fluxera/Fluxera.Guard</RepositoryUrl> | ||
<PackageProjectUrl>https://github.com/fluxera/Fluxera.Guard</PackageProjectUrl> | ||
<PackageIcon>icon.png</PackageIcon> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> | ||
<IncludeSymbols>false</IncludeSymbols> | ||
<NeutralLanguage>en</NeutralLanguage> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance> | ||
</PropertyGroup> | ||
|
||
</Project> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
next-version: 6.0.0 | ||
mode: Mainline | ||
|
||
branches: | ||
master: | ||
regex: ^master$|^main$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,79 @@ | ||
# Fluxera.Extensions | ||
[](https://dev.azure.com/fluxera/Foundation/_build/latest?definitionId=65&branchName=main) | ||
|
||
# Fluxera.Extensions | ||
A library that extends the Microsoft.Extensions.* libraries with custom functionality and also provices custom extensions. | ||
|
||
### ```Fluxera.Extensions.Caching``` | ||
|
||
This extension contains ```Option``` classes for configuring a remodee distributed cache server and | ||
several useful extension methods for the ```IDistributedCache``` service. | ||
|
||
### ```Fluxera.Extensions.Common``` | ||
|
||
This extension contains several custom services: | ||
|
||
- ```IDateTimeOffsetProvider``` A service that provides mockable access to static ```DateTimeOffset```. | ||
- ```IDateTimeProvider``` A service that provides mockable access to static ```DateTime```. | ||
- ```IGuidGenerator``` A service to generate ```Guid``` using different generators. | ||
- ```IHashCalculator``` A service to calculate hashes from input values. | ||
- ```IJitterCalculator``` A service that adds entropy to any given number. | ||
- ```IPasswordGenerator``` A service that generates random passwords. | ||
- ```IRetryDelayCalculator``` A service that calculates retry delay with (truncated) binary exponential back-off. | ||
- ```IStringEncryptionService``` A service that can be used to simply encrypt/decrypt texts. | ||
|
||
### ```Fluxera.Extensions.DataManagement``` | ||
|
||
This extension contains an infrastructure for insertng seed data to databases. | ||
|
||
### ```Fluxera.Extensions.DependencyInjection``` | ||
|
||
This extension contains several additions to the dependency injection extension. | ||
|
||
- Decorator | ||
- Add decorators to services. | ||
- Named Services | ||
- Add named service implementations. | ||
- Lazy Services | ||
- Add ```Lazy<T>``` as open generic sevice type. Any service will be resolved lazily from it. | ||
- Object Accessor | ||
- Provides a way to access object instances from the ```IServiceCollection``` while still configuring services. | ||
|
||
### ```Fluxera.Extensions.Http``` | ||
|
||
TODO | ||
|
||
### ```Fluxera.Extensions.Localization``` | ||
|
||
This extension contains several extension methods ```IStringLocalizer``` service. | ||
|
||
### ```Fluxera.Extensions.OData``` | ||
|
||
TODO | ||
|
||
### ```Fluxera.Extensions.Validation``` | ||
|
||
This extension provides an abstraction over validation frameworks. Any one framework can | ||
be used together with other ones. The validation results will merged by the extension. | ||
|
||
At the moment ```System.ComponentModel.Annotations``` and ```FluentValidation``` is supported. | ||
One can configure the validators to use like this: | ||
|
||
```C# | ||
IServiceCollection services = new ServiceCollection(); | ||
|
||
services.AddValidation(builder => | ||
{ | ||
builder | ||
.AddDataAnnotations() | ||
.AddFluentValidation(registration => | ||
{ | ||
registration.AddValidator<PersonValidator>(); | ||
}); | ||
}); | ||
``` | ||
|
||
|
||
## Resources | ||
|
||
https://stevetalkscode.co.uk/named-dependencies-part-1 | ||
https://stevetalkscode.co.uk/named-dependencies-part-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# CI pipeline for a NuGet package solution. | ||
|
||
trigger: | ||
branches: | ||
include: [ '*' ] | ||
exclude: [ 'refs/tags/*' ] | ||
|
||
variables: | ||
BuildConfiguration: Release | ||
DotNetCoreVersion: 6.0.100 | ||
|
||
stages: | ||
- stage: BuildAndTest | ||
jobs: | ||
- job: BuildAndTest | ||
pool: | ||
vmImage: 'windows-latest' | ||
steps: | ||
- checkout: self | ||
persistCredentials: 'true' | ||
clean: true | ||
# Run GitVersion to acquire the current build version. | ||
- task: GitVersion@5 | ||
displayName: 'Acquire and Apply Version' | ||
inputs: | ||
updateAssemblyInfo: true | ||
updateAssemblyInfoFilename: 'src/SolutionInfo.cs' | ||
additionalArguments: '/ensureassemblyinfo' | ||
configFilePath: 'GitVersion.yml' | ||
# Install the desired .NET SDK. | ||
- task: UseDotNet@2 | ||
displayName: 'Acquire .NET SDK' | ||
inputs: | ||
packageType: 'sdk' | ||
version: $(DotNetCoreVersion) | ||
includePreviewVersions: true | ||
# Build all projects. | ||
- task: DotNetCoreCLI@2 | ||
displayName: 'Build Projects' | ||
inputs: | ||
projects: '**/*.csproj' | ||
arguments: '--configuration $(BuildConfiguration)' | ||
nugetConfigPath: NuGet.config | ||
# Run all available tests. | ||
- task: DotNetCoreCLI@2 | ||
displayName: 'Execute Tests' | ||
inputs: | ||
command: test | ||
projects: '**/*Tests/*.csproj' | ||
arguments: '--configuration $(BuildConfiguration)' | ||
nobuild: true | ||
# Set the version to a environment variable. This will be used in the NuGet pack task. | ||
- script: echo %Action%%SemVerEnv% | ||
displayName: 'Set Package Version Variable' | ||
env: | ||
Action: '##vso[task.setvariable variable=NuGetPackageVersion]' | ||
SemVerEnv: $(GitVersion.SemVer) | ||
# Create the NuGet packages. | ||
- task: DotNetCoreCLI@2 | ||
displayName: 'NuGet Pack Packages' | ||
inputs: | ||
command: 'pack' | ||
packagesToPack: 'src/**/*.csproj' | ||
nobuild: true | ||
versioningScheme: 'byEnvVar' | ||
versionEnvVar: 'NuGetPackageVersion' | ||
verbosityPack: Minimal | ||
includesymbols: false | ||
# Copy created NuGet packages to the builds artifacts directory. | ||
- task: PublishBuildArtifacts@1 | ||
displayName: 'NuGet Publish Package Artifacts' | ||
inputs: | ||
PathtoPublish: '$(Build.ArtifactStagingDirectory)' | ||
ArtifactName: 'drop' | ||
publishLocation: 'Container' | ||
#- stage: DeployPackages | ||
# dependsOn: BuildAndTest | ||
# # Only publish packages for main, develop (alpha) and release (beta) branches. | ||
# condition: and(succeeded('BuildAndTest'), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) | ||
# jobs: | ||
# - job: DeployPackages | ||
# pool: | ||
# vmImage: 'windows-latest' | ||
# steps: | ||
# - checkout: self | ||
# persistCredentials: 'true' | ||
# clean: true | ||
# # Run GitVersion to acquire the current build version. | ||
# - task: GitVersion@5 | ||
# displayName: 'Acquire and Apply Version' | ||
# inputs: | ||
# updateAssemblyInfo: false | ||
# configFilePath: 'GitVersion.yml' | ||
# # Download the created packages. | ||
# - task: DownloadBuildArtifacts@0 | ||
# inputs: | ||
# buildType: 'current' | ||
# downloadType: 'single' | ||
# artifactName: 'drop' | ||
# downloadPath: '$(System.ArtifactsDirectory)' | ||
# # Publish the NuGet packages to the package feed. | ||
# # https://www.programmingwithwolfgang.com/azure-devops-publish-nuget/ | ||
# - task: DotNetCoreCLI@2 | ||
# condition: not(contains(variables['Build.BuildNumber'], '-ci')) | ||
# displayName: 'NuGet Push Packages' | ||
# inputs: | ||
# command: custom | ||
# custom: nuget | ||
# arguments: > | ||
# push $(System.ArtifactsDirectory)/**/*.nupkg | ||
# -s https://api.nuget.org/v3/index.json | ||
# -k $(NuGetApiKey) | ||
# #command: 'push' | ||
# #packagesToPush: '$(System.ArtifactsDirectory)/**/*.nupkg' | ||
# #nuGetFeedType: 'external' | ||
# #publishFeedCredentials: 'Foundation' | ||
# #verbosityRestore: Normal | ||
# #includesymbols: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "6.0.100" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
29 changes: 29 additions & 0 deletions
29
src/Fluxera.Extensions.Caching.Abstractions/CachingConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Fluxera.Extensions.Caching | ||
{ | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.Caching.Distributed; | ||
|
||
/// <summary> | ||
/// Provides the cache configuration for an entry in <see cref="IDistributedCache"/>. | ||
/// </summary> | ||
[PublicAPI] | ||
public sealed class CachingConfiguration | ||
{ | ||
public const string DefaultConnectionStringName = "Cache"; | ||
|
||
public CachingConfiguration() | ||
{ | ||
this.CacheEntryOptions = new DistributedCacheEntryOptions(); | ||
} | ||
|
||
/// <summary> | ||
/// Provides the cache options for an entry in <see cref="IDistributedCache"/>. | ||
/// </summary> | ||
public DistributedCacheEntryOptions CacheEntryOptions { get; set; } | ||
|
||
/// <summary> | ||
/// Provides the connection string to an external cache service. | ||
/// </summary> | ||
public string? ConnectionStringName { get; set; } = DefaultConnectionStringName; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Fluxera.Extensions.Caching.Abstractions/CachingOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Fluxera.Extensions.Caching | ||
{ | ||
using DataManagement; | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.Caching.Distributed; | ||
|
||
/// <summary> | ||
/// Provides the cache options for an entry in <see cref="IDistributedCache"/>. | ||
/// </summary> | ||
[PublicAPI] | ||
public sealed class CachingOptions | ||
{ | ||
public CachingOptions() | ||
{ | ||
this.Caching = new CachingConfiguration(); | ||
this.ConnectionStrings = new ConnectionStrings(); | ||
} | ||
|
||
/// <summary> | ||
/// Provides the caching configuration. | ||
/// </summary> | ||
public CachingConfiguration Caching { get; set; } | ||
|
||
/// <summary> | ||
/// Provides the connection strings. | ||
/// </summary> | ||
public ConnectionStrings ConnectionStrings { get; set; } | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Fluxera.Extensions.Caching.Abstractions/Fluxera.Extensions.Caching.Abstractions.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<PackageTags>fluxera;library;extensions;services;caching</PackageTags> | ||
<Description>The abstractions for the custom extensions for caching.</Description> | ||
<RootNamespace>$(MSBuildProjectName.Replace(" ", "_").Replace(".Abstractions",""))</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\SolutionInfo.cs" Link="Properties\SolutionInfo.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\README.md" Link="Properties\README.md"> | ||
<Pack>true</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
<None Include="..\..\icon.png" Link="Properties\icon.png"> | ||
<Pack>true</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Fluxera.Extensions.DataManagement.Abstractions\Fluxera.Extensions.DataManagement.Abstractions.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
4 changes: 4 additions & 0 deletions
4
src/Fluxera.Extensions.Caching.Abstractions/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyTitle("Fluxera.Extensions.Caching.Abstractions")] | ||
[assembly: AssemblyDescription("The abstractions for the custom extensions for caching.")] |
Oops, something went wrong.