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 MedianExtensions | |
{ | |
public static double Median(this IEnumerable<int> source) | |
{ | |
if (source == null) | |
throw new ArgumentNullException("source"); | |
var data = source.OrderBy(n => n).ToArray(); | |
if (data.Length == 0) | |
throw new InvalidOperationException(); | |
if (data.Length % 2 == 0) |
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; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.ComponentModel.DataAnnotations; | |
using System.Data.Entity; | |
using System.Data.Entity.Infrastructure; | |
using System.Data.Entity.SqlServer; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; |
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.Diagnostics; | |
namespace System.Numerics.Benchmark | |
{ | |
public class Program | |
{ | |
private static readonly Random s_random = new Random(1138); | |
private static int s_bits = 4096; | |
private static int s_vals = 100; |
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 EnumerableExtensions | |
{ | |
public static IEnumerable<T> Flatten<T>(this T value, Func<T, T> inner, T tail = default(T)) | |
{ | |
var comparer = EqualityComparer<T>.Default; | |
while (!comparer.Equals(value, tail)) | |
{ | |
yield return value; | |
value = inner(value); | |
} |
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; | |
using System.ComponentModel.DataAnnotations; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
namespace System.Data.Entity | |
{ | |
internal static class DbSeeder | |
{ |
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; | |
using System.Linq; | |
using System.Management.Automation; | |
using System.Reflection; | |
using System.Runtime.Loader; | |
namespace MyModule | |
{ | |
public class Resolver : AssemblyLoadContext, IModuleAssemblyInitializer, IModuleAssemblyCleanup | |
{ |
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
function ConvertTo-CentralPackageManagement() { | |
Write-Host 'Searching for package references' | |
$packages = @{} | |
$conditionalPackages = @{} | |
foreach ($csproj in (Get-ChildItem -Include *.csproj, *.props -Recurse)) { | |
$root = [xml]($csproj | Get-Content -Raw) | |
foreach ($itemGroup in $root.Project.ItemGroup) { | |
foreach ($packageReference in $itemGroup.PackageReference) { | |
if ($packageReference.Include -and $packageReference.Version) { |