Skip to content

Commit

Permalink
Added the initial version. (#1)
Browse files Browse the repository at this point in the history
* 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
mgernand authored Dec 12, 2021
1 parent 436bebe commit f47ca94
Show file tree
Hide file tree
Showing 192 changed files with 8,257 additions and 2 deletions.
36 changes: 36 additions & 0 deletions Directory.Build.props
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>
219 changes: 219 additions & 0 deletions Fluxera.Extensions.sln

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions GitVersion.yml
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$
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Fluxera Software Development GmbH
Copyright (c) 2014-2021 Fluxera Software Development GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,79 @@
# Fluxera.Extensions
[![Build Status](https://dev.azure.com/fluxera/Foundation/_apis/build/status/GitHub/fluxera.Fluxera.Extensions?branchName=main)](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
118 changes: 118 additions & 0 deletions azure-pipelines.yml
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
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "6.0.100"
}
}
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

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 src/Fluxera.Extensions.Caching.Abstractions/CachingOptions.cs
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; }
}
}
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>
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.")]
Loading

0 comments on commit f47ca94

Please sign in to comment.