Dan’s technical ramblings

So how about truly private fields in C#?

May 21st, 2009 Posted in Uncategorized | 1 Comment »

UPDATE: Jim pointed out that you can access the field via reflecting over the delegate.  (See comment) Damn this is a bit like how java does anonymous access to private fields of the parent class. I wonder if you could use this for some nasty security violations as people tend to think local variables are safe from reflection.

After the crazy !@$%  with JavaScript yesterday I said to Christian, I bet we can do this with C# lambda. So the challenge was set….


class Purse
{
public Func<int> get;
public Action<int> set;

public Purse(int money)
{
get = () => { return money; };
set = (newMoney) => { money = newMoney ; };
}
}

And here is the test …


var p = new Purse(2);
p.set(p.get() + 1);
Assert.AreEqual(3, p.get());

If you tried to use reflection, as expected there is no field to inspect.

Truly private fields in JavaScript

May 21st, 2009 Posted in web | No Comments »

Pairing with Resharper (Switching Keyboard Layouts in Visual Studio)

December 2nd, 2008 Posted in pairing, resharper | 1 Comment »

Lean and the fishing industry

November 7th, 2008 Posted in lean | No Comments »

The implicit back link

April 14th, 2008 Posted in web | No Comments »

Plaxo revisited

April 13th, 2008 Posted in plaxo | 1 Comment »

Early morning rant…

April 9th, 2008 Posted in plaxo | 2 Comments »

Gave my first public presentation…

April 4th, 2008 Posted in progressive enhancement | 1 Comment »

More Ubuntu 7.10 notes for Dell D630

December 29th, 2007 Posted in ubuntu | 4 Comments »

Notes on installing Ubuntu Gutsy Gibbon 64bit edition on a Dell D630

November 8th, 2007 Posted in ubuntu | No Comments »