Thursday 23 May 2013

Xbox One Menu

image

image

image

image

image

image

Some nice HTML and CSS bits and pieces

https://aligntoday.com/Application/login.aspx

image

https://aligntoday.com/sales/request-demo.aspx

image

Gauge:  http://thecodeplayer.com/walkthrough/make-gauge-charts-using-canvas-and-javascript

image

Accordion menu:  http://thecodeplayer.com/walkthrough/vertical-accordion-menu-using-jquery-css3

image

Stop watch:  http://thecodeplayer.com/walkthrough/make-a-stopwatch-using-css3-without-images-or-javascript

image

Family tree:  http://thecodeplayer.com/walkthrough/css3-family-tree

image

Image slider(ish):  http://thecodeplayer.com/walkthrough/make-an-accordian-style-slider-in-css3

image

Overloading methods for derived classes

Using dynamic keyword to resolve double dispatch, overloaded methods using derived types at compile time.

image

using System;
using System.Collections.Generic;
using System.Reflection;

namespace OverloadedMethod
{
class Program
{
static void Main(string[] args)
{
var processor = new Processor();
var shapes = new List<Shape> {new Circle(), new Triangle()};

foreach (var shape in shapes)
{
// option 1
processor.GetType()
.GetMethod("Execute",
BindingFlags.Instance | BindingFlags.NonPublic,
null,
new[] { shape.GetType() },
null)
.Invoke(processor,
new object[] { shape });

// or option 2 (requires known definition of all drived types and a line per type)
if (shape is Circle) processor.Execute(shape as Circle);
else if (shape is Triangle) processor.Execute(shape as Triangle);

// option 3... BOOM!!!! Works a treat :)
processor.Execute(shape as dynamic);
}
}
}

class Shape { }

class Circle : Shape
{
public int Circumference { get { return 10; } }
}

class Triangle : Shape
{
public int HypotenuseLength { get { return 20; } }
}

class Processor
{
internal void Execute(Circle circle)
{
Console.WriteLine("Executing with a Circle with circumference {0}!", circle.Circumference);
}

internal void Execute(Triangle triangle)
{
Console.WriteLine("Executing with a Triangle hypotenuse length of {0}!", triangle.HypotenuseLength);
}
}
}


Source:  https://github.com/stevenh77/OverloadedMethod/


So what about this, using an extension method?  Apparently Circle doesn’t have a definition for Execute…


image


Source:  https://github.com/stevenh77/OverloadedMethodExtensions/

using System;
using System.Collections.Generic;

namespace OverloadedMethod
{
class Program
{
static void Main(string[] args)
{
var shapes = new List<Shape> {new Circle(), new Triangle()};

foreach (var shape in shapes)
{
// option 4: so what about this....?
// (shape as dynamic).Execute(); // doesn't work
ExtensionMethods.Execute(shape as dynamic); // this works!
}
}
}

class Shape { }

class Circle : Shape
{
public int Circumference { get { return 10; } }
}

class Triangle : Shape
{
public int HypotenuseLength { get { return 20; } }
}

static class ExtensionMethods
{
public static void Execute(this Circle circle)
{
Console.WriteLine("Executing with a Circle with circumference {0}!", circle.Circumference);
}

public static void Execute(this Triangle triangle)
{
Console.WriteLine("Executing with a Triangle hypotenuse length of {0}!", triangle.HypotenuseLength);
}
}
}

Sunday 19 May 2013

TortoiseSVN hidden features

Hold down the shift key before right clicking on a SVN repo and you see some hidden features! :)

image