Skip to content

Instantly share code, notes, and snippets.

View svick's full-sized avatar

Petr Onderka svick

View GitHub Profile
@svick
svick / ico.cs
Created February 11, 2011 13:25
using System;
using System.Net;
using System.Xml;
using System.Linq;
public class Test
{
public static void Main()
{
Console.Write("ICO: ");
@svick
svick / Program.cs
Created April 24, 2011 11:45
DynamicObject
using System;
using System.Dynamic;
namespace ConsoleApplication1
{
class Dynamic : DynamicObject
{
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (binder.Name == "Name")
@svick
svick / AnotherContinent.cs
Created May 31, 2011 19:10
Mock of how could you call a method on another computer using DynamicProxy and pseudo-JSON
using System;
using System.Linq;
using Castle.DynamicProxy;
namespace AnotherContinent
{
class Program
{
static void Main()
{
@svick
svick / Program.cs
Created April 23, 2012 18:09
async and SQL
using System;
using System.Data.SqlClient;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
@svick
svick / Program.cs
Created September 3, 2012 13:38
SO Task inlining
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
public abstract CategoryInfoResult CategoryInfo { get; }
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
namespace Dataflow_tmp
{
static class Program
{
private static void Main()
using System;
using System.Collections.Generic;
using System.Linq;
using HtmlAgilityPack;
namespace nuget_tmp
{
static class Program
{
private static void Main()
static bool WaitAll(Task[] tasks, int timeout, CancellationToken token)
{
var cts = CancellationTokenSource.CreateLinkedTokenSource(token);
foreach (var task in tasks)
{
task.ContinueWith(t => {
if (t.IsFaulted) cts.Cancel();
},
cts.Token,
@svick
svick / Program.cs
Created August 22, 2014 22:48
C# 6.0 primary constructor accessibility
class Program
{
static void Main()
{
new PublicConstructor(""); // OK
new PrivateConstructor(""); // error CS0122: 'Program.PrivateConstructor.PrivateConstructor(string)' is inaccessible due to its protection level
new PrimaryConstructor(""); // OK
}
private class PrimaryConstructor(string firstName)