Skip to content

Instantly share code, notes, and snippets.

@a4099181
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 = "https://gist.githubusercontent.com/a4099181/074a6c3dd524ea0d343382137492399c/raw/cdd0fb31efd70c4c0f8c86ddb314de86ab8972e8/Convert-ToPackageReference.xsl",
[String] $resultsFile = [System.IO.Path]::GetTempFileName() )
Process {
$xslt = New-Object System.Xml.Xsl.XslCompiledTransform
$xslt.Load( $stylesheetUri )
$xslt.Transform( $inputUri, $resultsFile )
@joeriks
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
{
@marckm
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="http://msdn.microsoft.com/en-us/library/ms157901.aspx" />
@jmcd
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;
}