Skip to content

Instantly share code, notes, and snippets.

@aelij
aelij / AwaitExtensions2.cs
Last active May 3, 2019
Improved TaskAwaiters for Silverlight that provide better stack traces for exceptions
View AwaitExtensions2.cs
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace MyApp
{
/// <summary>
/// Replaces Microsoft.Bcl.Async extensions and provides more detailed stack traces
View InstallNetFx461.ps1
#Requires -Version 3.0
<#
.DESCRIPTION
Install .Net Framework 4.6.1
#>
[CmdletBinding()]
Param(
@aelij
aelij / Startup.cs
Created Jan 7, 2016
Hosting ASP.NET 5 in a .csproj without DNX
View Startup.cs
using System.Linq;
using System.Reflection;
using AspNetNoDnx.Runtime;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
@aelij
aelij / AsyncStackTrace.cs
Last active Feb 19, 2016
Improved async stack trace
View AsyncStackTrace.cs
// see the full featured library at
// https://github.com/aelij/asyncstacktrace
@aelij
aelij / -Usage.cs
Last active Aug 20, 2020
IAsyncEnumerable Bridge for Service Fabric Reliable Collections
View -Usage.cs
class MyService : StatefulService
{
private Task<IReliableDictionary<int, string>> AccountNames => StateManager.GetOrAddAsync<IReliableDictionary<int, string>>("AccountNames");
private Task<IReliableDictionary<int, string>> AccountData => StateManager.GetOrAddAsync<IReliableDictionary<int, string>>("AccountData");
public async Task<List<Account>> SearchAccountsByNameAsync(string name)
{
using (var txn = StateManager.CreateTransaction())
{
var accountNames = await AccountNames;
@aelij
aelij / cs7-match.csx
Last active Apr 20, 2016
C# 7 Experiments for RoslynPad
View cs7-match.csx
abstract class Animal { }
class Dog : Animal
{
public string Bark() => "Woof";
}
class Cat : Animal
{
public string Meow() => "Meow";
@aelij
aelij / ThemeManager.cs
Created Jul 4, 2016
WPF Theme Manager
View ThemeManager.cs
using System;
using System.Reflection;
using System.Windows;
public static class ThemeManager
{
#region Fields
private const BindingFlags DefaultStaticFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
private const BindingFlags DefaultInstanceFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
View AsyncEnumerableGenerator.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security;
using System.Threading;
using System.Threading.Tasks;
@aelij
aelij / Download-ServiceFabricImageStoreContent.ps1
Created Mar 9, 2017
Cmdlet that downloads files from Service Fabric's image store
View Download-ServiceFabricImageStoreContent.ps1
# Examples:
#
# List image store content:
# $connectionString = Get-ServiceFabricImageStoreConnectionString
# Get-ServiceFabricApplicationType | % { Get-ServiceFabricImageStoreContent -Application -ApplicationTypeName $_.ApplicationTypeName -ApplicationTypeVersion $_.ApplicationTypeVersion -ImageStoreConnectionString $connectionString }
# > StoreRelativePath : Store\Application1Type\Stateless1Pkg.Code.1.0.0
# > Type : Folder [5 files]
# > ServiceManifestName : Stateless1Pkg
# > ServiceManifestVersion : 1.0.0
# > ApplicationVersion : 1.0.0
@aelij
aelij / Create-ServiceFabricApplicationPackageSkeleton.ps1
Created Mar 9, 2017
Cmdlet to create a skeleton Service Fabric application package from the image store. Can be used for partial configuration/data packages upgrades.
View Create-ServiceFabricApplicationPackageSkeleton.ps1
function Create-ServiceFabricApplicationPackageSkeleton
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[string] $ApplicationTypeName,
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[string] $ApplicationTypeVersion,
You can’t perform that action at this time.