Created
May 17, 2011 01:48
-
-
Save juanplopes/975740 to your computer and use it in GitHub Desktop.
Property paradox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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