Skip to content

Instantly share code, notes, and snippets.

@chrissie1
chrissie1 / GoodLanguage
Created February 22, 2013 10:46
I don't want ICommandWithParameter<object> to be of object I want it to be this ICommandWithParameter<TParameterType>. Where am I going wrong. I now wrote badtest to make it pass but I would like to write whatIWantTest. But I could not find a good way to configure the method constraints to do that. I can make this work perfectly in VB.
Namespace Commands
Public Class CommandExecuter
Public Sub Execute(Of TCommand As {ICommand, New})()
Dim command = New TCommand()
command.Execute()
End Sub
Public Sub Execute(Of TCommand As {ICommandWithParameter(Of TParameter), New}, TParameter)(ByVal parameter As TParameter)
Dim command = New TCommand()
@chrissie1
chrissie1 / PackageSorter.cs
Last active December 13, 2015 18:58
Sorting chcolatey Pacakges On version
using System;
using System.Collections.Generic;
namespace OrderPackages
{
public class PackagesSorter:IComparer<string>
{
private static readonly char LevelSeperator = ".".ToCharArray()[0];
private const string PreRelease = "-pre";
@chrissie1
chrissie1 / gist:4299744
Created December 15, 2012 22:09
This should work but needs some locking on the set.
internal static class Container
{
private static class PerType<T>
{
public static ILog Log;
}
public static ILog GetOrAdd<T>()
{
var log = PerType<T>.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
Module Module1
Sub Main()
Dim s = New subclass
s.test()
Console.ReadLine()
End Sub
Public Interface IInterface
Sub test()
@chrissie1
chrissie1 / gist:3372616
Created August 16, 2012 18:53
this should fail. In old VB.
Imports System.Dynamic
Module Module1
Sub Main()
Dim c2 As Object = New C
using EasyHttp.Infrastructure;
using Machine.Specifications;
namespace EasyHttp.Specs.Specs
{
public class When_baseuri_is_null_and_query_is_null
{
Establish context = () =>
{
uriComposer = new UriComposer();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlServerCe;
namespace SimpleDataC
{
class Program
{
Option Strict Off
Imports System.Data.SqlServerCe
Imports System.IO
Module Module1
Sub Main()
CreateDatabase()
CreateTables()
# variables
$url = "http://packages.nuget.org/v1/Package/Download/Chocolatey/0.9.8.4"
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "chocInstall"
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)}
$file = Join-Path $tempDir "chocolatey.zip"
# download the package
Write-Host "Downloading $url to $file"
$downloader = new-object System.Net.WebClient