Skip to content

Instantly share code, notes, and snippets.

View jvanlangen's full-sized avatar

Jeroen van Langen jvanlangen

View GitHub Profile
@jvanlangen
jvanlangen / CreateConstructor.cs
Created March 21, 2020 00:27
Constructor generator using Expressions
// this delegate is just, so you don't have to pass an object array. _(params)_
public delegate object ConstructorDelegate(params object[] args);
public static ConstructorDelegate CreateConstructor(Type type, params Type[] parameters)
{
// Get the constructor info for these parameters
var constructorInfo = type.GetConstructor(parameters);
// define a object[] parameter
var paramExpr = Expression.Parameter(typeof(Object[]));
@jvanlangen
jvanlangen / MainWindow.xaml
Created November 3, 2019 01:47
WPF Move controls
<Window x:Class="WPFTestControlMoveMouse.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFTestControlMoveMouse"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
@jvanlangen
jvanlangen / ASyncThread.cs
Last active October 22, 2019 08:02
ASync/Await Enabled Threads in C#
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
namespace VanLangen
{
public class ASyncThread : IDisposable
{
// By JvanLangen.