Skip to content

Instantly share code, notes, and snippets.

View Net48WebApp.OutDir.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591;CA1724;CS1574</NoWarn>
<OutDir>$(MSBuildProjectDirectory)\bin\</OutDir>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
View Net48WebApp.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591;CA1724;CS1574</NoWarn>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
View Extensions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Dependencies;
using Microsoft.Extensions.DependencyInjection;
View DependencyInjection.AspNet.WebApi.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
</ItemGroup>
View WebApiApplication.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Dependencies;
using System.Web.Http.ExceptionHandling;
View RangeOperatorTestFunction.ps1
function ffff($Value) {
switch($Value) {
{0..24 -contains $_} { $a = 0 }
{25..49 -contains $_} { $a = 1 }
{50..74 -contains $_} { $a = 2 }
{75..99 -contains $_} { $a = 3 }
}
}
View Get-RandomConjunction.ps1
function Get-RandomConjunction {
[CmdletBinding()]
param()
$Chance = Get-RandomPercent
switch ($Chance) {
{ 1..45 -contains $_ } { 'and' } # 45% chance for 'and'
{ 46..75 -contains $_ } { 'or' } # 25% chance for 'or'
{ 76..85 -contains $_ } { ',' } # 10% chance for 'comma'
{ 86..95 -contains $_ } { ';' } # 10% chance for 'semi-colon'
{ 96..100 -contains $_ } { ':' } # 5% chance for 'colon'
View SwitchPerformanceTest.ps1
function RangeOperatorInFunc($Value) {
switch($Value) {
{0..24 -contains $_} { $a = 0 }
{25..49 -contains $_} { $a = 1 }
{50..74 -contains $_} { $a = 2 }
{75..99 -contains $_} { $a = 3 }
}
}
$gr1 = 0..24;
View Startup.cs
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ApplicationInsights;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
You can’t perform that action at this time.