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
using Microsoft.EntityFrameworkCore; | |
public abstract class EntityBase<TKey> where TKey : IEquatable<TKey> | |
{ | |
public abstract TKey Id { get; set; } | |
} | |
public abstract class RepositoryBase<TDbContext, TEntity, TKey> | |
where TDbContext : DbContext, new() | |
where TEntity : EntityBase<TKey> |
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<Title>Morris.Extensions.Aspire.ExternalSolutionSupport</Title> | |
<PackageId>Morris.Extensions.Aspire.ExternalSolutionSupport</PackageId> | |
<Description>Referenced Solutions support for Aspire</Description> | |
<Nullable>enable</Nullable> | |
<ImplicitUsings>true</ImplicitUsings> | |
<IncludeBuildOutput>false</IncludeBuildOutput> | |
<IsRoslynComponent>true</IsRoslynComponent> | |
<TargetFramework>netstandard2.0</TargetFramework> |
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net8.0</TargetFramework> | |
<ImplicitUsings>enable</ImplicitUsings> | |
<Nullable>enable</Nullable> | |
</PropertyGroup> | |
<ItemGroup> |
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
static readonly char[] ExtractFloatsTrimChars = new char[] { '[', ']', ' ' }; | |
static float[] ExtractFloats(string input) => | |
input | |
.Trim(ExtractFloatsTrimChars) | |
.Split(',') | |
.Select(float.Parse) | |
.ToArray(); |
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
public class ActivityTrackingMiddleware : IFunctionsWorkerMiddleware | |
{ | |
public const string ActivitySourceName = "AzureFunctionsWorker"; | |
private readonly static ConcurrentDictionary<string, TriggerParameterInfo> FunctionIdToTriggerParameterInfoLookup = new(); | |
private readonly static ActivitySource ActivitySource = new(ActivitySourceName); | |
private readonly HttpTriggerHandler HttpTriggerHandler; | |
private readonly ActivityTriggerHandler ActivityTriggerHandler; | |
private readonly FrozenDictionary<string, ICustomTriggerHandler> CustomTriggerHandlers; |
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
using MyApp.Contracts; | |
using Community.OData.Linq; | |
using Microsoft.EntityFrameworkCore; | |
namespace CarePlace.AppLayer.Persistence; | |
internal static class IQueryableExtensions | |
{ | |
public static IQueryable<T> ApplyODataParameters<T>( | |
this IQueryable<T> source, |
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
internal class IdentityService : IIdentityService | |
{ | |
// Other properties like the current user etc | |
public bool IsRunningWithElevatedPrivileges => ElevatedPrivilegeCount > 0; | |
private volatile int ElevatedPrivilegeCount; | |
public IDisposable ExecuteWithElevatedPrivileges() | |
{ | |
Interlocked.Increment(ref ElevatedPrivilegeCount); | |
return new DisposableCallback(() => Interlocked.Decrement(ref ElevatedPrivilegeCount)); |
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
public sealed class DisposableCallback : IDisposable | |
{ | |
private readonly Action Action; | |
private readonly string CallerFilePath; | |
private readonly int CallerLineNumber; | |
private readonly bool WasCreated; | |
private bool IsDisposed; | |
/// <summary> | |
/// Creates an instance of the class |
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
public static class IntegrationTestsServer | |
{ | |
static IntegrationTestsServer() | |
{ | |
ConfigureMocks(); | |
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "IntegrationTesting"); | |
WebApplicationFactory<Program> appBuilder = new WebApplicationFactory<Program>() | |
.WithWebHostBuilder(builder => | |
{ | |
builder.ConfigureTestServices(services => |
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
public static class StringHelper | |
{ | |
public const byte DefaultUnobscuredLength = 3; | |
public enum Keep { Start, End }; | |
public static string? ObscureEmailAddress(string? value) | |
{ | |
if (string.IsNullOrEmpty(value)) | |
return value; |
NewerOlder