Skip to content

Instantly share code, notes, and snippets.

@juanplopes
Created May 17, 2011 01:48
Show Gist options
  • Save juanplopes/975740 to your computer and use it in GitHub Desktop.
Save juanplopes/975740 to your computer and use it in GitHub Desktop.
Property paradox
public class PropertyWrapper : IFixture
{
class TestClass
{
public string TestProperty { get; set; }
}
public void Execute(Runner my)
{
var prop = typeof(TestClass).GetProperty("TestProperty");
var obj = new TestClass();
my.Execute("raw", () =>
{
obj.TestProperty = "asd";
});
var stdDel = (Action<TestClass, string>)Delegate.CreateDelegate(typeof(Action<TestClass, string>), prop.GetSetMethod());
my.Execute("stddel", () =>
{
stdDel(obj, "asd");
});
}
}
PropertyWrapper
raw : 00:00:00.0003588
stddel : 00:00:00.0002367
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment