Skip to content

Instantly share code, notes, and snippets.

View dbeattie71's full-sized avatar

Derek Beattie dbeattie71

  • Nebraska
  • 14:42 (UTC -05:00)
View GitHub Profile
@dbeattie71
dbeattie71 / ConvertTo-CentralPackageManagement.ps1
Created July 25, 2024 14:16 — forked from axelheer/ConvertTo-CentralPackageManagement.ps1
Generates a `Directory.Packages.props` based on all your project files
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) {
@dbeattie71
dbeattie71 / Program.cs
Created February 14, 2024 22:36 — forked from madcodemonkey/Program.cs
Generate SSRS report using WCF in .NET Core Application
using ServiceReference1;
using System;
using System.Collections.Generic;
using System.IO;
using System.ServiceModel;
using System.Threading.Tasks;
namespace SSRSSimple
{
class Program
public class AuthenticatingHandler<T> : DelegatingHandler where T : ISecurityTokenAccessor
{
private readonly Policy<HttpResponseMessage> _policy;
private readonly T _securityTokenAccessor;
private IAccessToken _accessToken;
private AuthenticationHeaderValue _authenticationHeader;
public AuthenticatingHandler(T securityTokenAccessor)
{
_securityTokenAccessor = securityTokenAccessor;
@dbeattie71
dbeattie71 / pipelinetest.cs
Created March 23, 2018 21:12 — forked from itn3000/pipelinetest.cs
System.IO.Pipelines tests
using System;
using System.Collections;
using System.Collections.Generic;
struct TestEnumerator<T> : IEnumerator<T>
{
ArraySegment<T> m_Segment;
public TestEnumerator(ref ArraySegment<T> seg)
{
m_Segment = seg;
}
@dbeattie71
dbeattie71 / Example1.cs
Created February 28, 2018 23:17 — forked from davidfowl/Example1.cs
How .NET Standard relates to .NET Platforms
namespace Analogy
{
/// <summary>
/// This example shows that a library that needs access to target .NET Standard 1.3
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library.
/// </summary>INetCoreApp10
class Example1
{
public void Net45Application(INetFramework45 platform)
@dbeattie71
dbeattie71 / NntpDecompressingConnection.cs
Created December 8, 2017 20:07 — forked from keimpema/NntpDecompressingConnection.cs
A decompresing INntpConnection implementation (not very good)
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Security;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using Microsoft.Extensions.Logging;
public static class Coroutine {
public static void BeginExecute(IEnumerable<Promise> enumerable) {
MoveNext(enumerable.GetEnumerator());
}
static void MoveNext(IEnumerator<Promise> enumerator) {
if (enumerator.MoveNext()) {
var promise = enumerator.Current;
promise.Current = promise.Task();
promise.Current._CallBack = () => MoveNext(enumerator);
using System;
using System.Diagnostics;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace FileAnalyzer
{
public static unsafe class NativeRecord
using System;
using System.Diagnostics;
using System.IO;
using System.IO.MemoryMappedFiles;
namespace FileAnalyzer
{
public static unsafe class NativeRecord
{
private static readonly int[] DaysToMonth365 =
@dbeattie71
dbeattie71 / Dumper.cs
Created February 10, 2017 21:15 — forked from DTTerastar/Dumper.cs
Nice easy way of getting formatted C# like serialized text from object graphs. Nice to use for creating unit tests, or checking on intermediary values while debugging.
public static class DumperExtensions
{
public static string DumpToString(this object a, int maxDepth = 16, bool breakCircularRefs = false)
{
return new Dumper(a, maxDepth, breakCircularRefs).ToString();
}
public static T DumpToConsole<T>(this T a, int maxDepth = 16, bool breakCircularRefs = false)
{
Console.Out.WriteLine(DumpToString(a, maxDepth, breakCircularRefs));