This file contains hidden or 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
using Polly; | |
using Polly.Contrib.WaitAndRetry; | |
namespace CSharp.Tools | |
{ | |
public abstract class AbstractHandler | |
{ | |
/// <summary> | |
/// Regular "do work" | |
/// </summary> |
This file contains hidden or 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
public static class ClassUtils | |
{ | |
private static List<string> Enumerables = new List<string>() { "IList", "ICollection", "IEnumerable", "IReadOnlyList", "IReadOnlyCollection" }; | |
public static object GetPropertyValue<T>(T source, string property) | |
{ | |
if (!property.Contains(".")) | |
return GetProperty(source, property); | |
var path = property.Split(new[] { '.' }, 2); |
This file contains hidden or 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
using Moq; | |
namespace BaseMock | |
{ | |
public partial class BaseMock<TInterface, TAdapter> | |
where TInterface : class | |
where TAdapter : class, new() | |
{ | |
protected readonly Mock<TInterface> mock = new(); |
This file contains hidden or 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
// Pre build events | |
if $(ConfigurationName) == Release ( | |
del *.nupkg | |
echo "[PRE-BUILD] Deleted old *.nupkg" | |
) | |
// Post Build events | |
echo "[POST-BUILD] Started" |
This file contains hidden or 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
public class PrivateObject<T> | |
{ | |
private object o; | |
public PrivateObject(object o) | |
{ | |
this.o = o; | |
} | |
public object Invoke(string methodName, params object[] args) |
This file contains hidden or 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
using Microsoft.Extensions.DependencyInjection; | |
using Moq; | |
using System; | |
namespace ServiceProviderFactory | |
{ | |
public static class ServiceProviderFactory | |
{ | |
public static Mock<IServiceProvider> GetServiceProvider(params (Type @interface, object service)[] services) | |
{ |
This file contains hidden or 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
--------------- dependencies | |
dotnet tool install --global dotnet-sonarscanner --version 5.2.0 | |
dotnet tool update dotnet-reportgenerator-globaltool -g --version 4.8.7 | |
--------------- runsonnar.bat | |
dotnet sonarscanner begin /k:"<project name>" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="<login>" /d:sonar.coverageReportPaths=".\sonarqubecoverage\SonarQube.xml" | |
dotnet build | |
dotnet test --no-build --collect:"XPlat Code Coverage" |
This file contains hidden or 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
using Microsoft.EntityFrameworkCore; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection.Metadata; | |
using System.Threading.Tasks; | |
namespace BaseRepository | |
{ |
This file contains hidden or 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
public static class FilterExtensions | |
{ | |
public static DynamicFilterBuilder<T> Filter<T>(this T sourceEntity, Action<DynamicFilterBuilder<T>> filter) | |
{ | |
var filterBuilder = new DynamicFilterBuilder<T>(); | |
return filterBuilder.And(filter); | |
} | |
public static Expression<Func<T, bool>> Build<T>(this DynamicFilterBuilder<T> filterBuilder) |
This file contains hidden or 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
public static class ConfigurationFactory | |
{ | |
public static IConfiguration GetConfiguration(string file = null) | |
{ | |
var configuration = new ConfigurationBuilder() | |
.AddJsonFile(file ?? "appsettings.json") | |
.Build(); | |
return configuration; | |
} |
OlderNewer