-
Create your App Service, Key Vault, and Application Insights
- Copy the Key Vault's "Vault URI" for later
- Copy the Application Insights' "Connection String" for later
-
In the App Service's "Identity", turn the "System assigned" "Status" to "On"
-
In the App Service's "Configuration", create a "New application setting" with value "KeyVaultURI", and value of the "Vault URI" you copied in step 1
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 PaginatedResults<T> | |
{ | |
public required IReadOnlyList<T> Results { get; init; } | |
public required int Page { get; init; } | |
public required int PageSize { get; init; } | |
public required int TotalCount { get; init; } | |
public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize); | |
} |
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 System.Reflection; | |
using BenchmarkDotNet.Running; | |
// put all the benchmark classes into their own namespace, for easier discoverability. if you don't like this, | |
// change the next few lines to find your benchmarks using whatever logic you prefer. | |
const string BenchmarksNamespace = "YourBenchmarkNamespaceHere.Benchmarks"; | |
var allBenchmarks = Assembly.GetExecutingAssembly() | |
.GetTypes() | |
.Where(t => t is { Namespace: BenchmarksNamespace, IsClass: true }) |
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> | |
<TargetFramework>net7.0</TargetFramework> | |
<ImplicitUsings>enable</ImplicitUsings> | |
<Nullable>enable</Nullable> | |
<WarningsAsErrors>Nullable</WarningsAsErrors> | |
</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
[*.cs] | |
dotnet_diagnostic.IDE0005.severity = error # unnecessary using directives | |
dotnet_diagnostic.IDE0035.severity = error # unreachable code | |
dotnet_diagnostic.IDE0059.severity = error # unnecessary value assignment | |
dotnet_diagnostic.IDE0060.severity = error # unused parameter |
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 DateTimeOffsetExtensions | |
{ | |
private const double MoonCycleLength = 29.53058868; | |
public static MoonPhase ComputeMoonPhase(this DateTimeOffset dt) | |
{ | |
return dt.GetMoonAge() switch | |
{ | |
< 1.84566 => MoonPhase.NewMoon, |
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 System.DirectoryServices.AccountManagement; | |
using System.Runtime.InteropServices; | |
using System.Security.Principal; | |
using Microsoft.Win32.SafeHandles; | |
namespace YourNamespaceHere; | |
// Notes: | |
// * This class is a service. Hopefully you've got a DI/IoC container you can register it with. (For a desktop application, | |
// it'd probably make the most sense as a singleton.) |
I translated the following methods from Java, for use in C#, over a year ago (sometime in early 2022, or late 2021). Maybe there's better versions of the same elsewhere; I dunno. If this is the best that you - o weary traveller of the internet - could find, then I hope you find them useful for your purposes.
You know SQL injection attacks? Well, there's LDAP injection attacks, too.
The following method escapes values which you're tossing into LDAP search strings.
NewerOlder