Skip to content

Instantly share code, notes, and snippets.

jmcd / LambdaExpressionFactory.cs
Created August 1, 2012 11:30
Runtime generation of a lambda of member-expression
public class LambdaExpressionFactory
// With member type
public static Expression<Func<T, TProperty>> Lambda<T, TProperty>(string memberName)
var parameterExpression = Expression.Parameter(typeof(T), "x");
var memberExpression = Expression.PropertyOrField(parameterExpression, memberName);
var result = (Expression<Func<T, TProperty>>)Expression.Lambda(memberExpression, parameterExpression);
return result;
marckm / CustomContext
Created October 16, 2012 14:18
Custom context managing application context with NotifyIcon
namespace NoFormApplication
using System;
using System.Windows.Forms;
using NoFormApplication.Properties;
/// <summary>
/// Application specific context used to create application's main standard loop without form.
/// </summary>
/// <see cref="" />
joeriks / program.cs
Created September 20, 2013 08:06
One file simple usage WebApi selfhost (console program + Microsoft.AspNet.WebApi.SelfHost nuget). Needs to be run as admin.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http.SelfHost;
using System.Web.Http;
namespace ConsoleApplication1
a4099181 / Convert-ToPackageReference.ps1
Last active February 18, 2021 07:00
Converts packages.config into PackageReference at *.csproj project file. Requires XSLT stylesheet available as second file in the gist.
Function Convert-ToPackageReference
Param ( [Parameter( Mandatory, ValueFromPipeline )][String] $inputUri,
[String] $stylesheetUri = "",
[String] $resultsFile = [System.IO.Path]::GetTempFileName() )
Process {
$xslt = New-Object System.Xml.Xsl.XslCompiledTransform
$xslt.Load( $stylesheetUri )
$xslt.Transform( $inputUri, $resultsFile )