Skip to main content
12 events
when toggle format what by license comment
Jun 30, 2018 at 6:20 vote accept Amir Movahedi
Jul 14, 2014 at 10:19 history migrated from stackoverflow.com (revisions)
Jul 12, 2014 at 2:26 comment added DavidG @JohnathonSullinger much of the code appears to be wasted though
Jul 12, 2014 at 2:25 comment added Johnathon Sullinger @DavidG My mistake, I missed that.
Jul 12, 2014 at 2:25 comment added DavidG @JohnathonSullinger not true, he's recursing each property.
Jul 12, 2014 at 2:18 comment added Johnathon Sullinger You really need to provide a more complete example. Your example provided shows that nothing is happening with the reflected data. You use reflection, loop through all of the properties, but do nothing with it. In the end, you just pass item in to the SaveInCache method, and discard everything you reflected.
Jul 12, 2014 at 2:14 comment added bingles As mentioned in the last comment, you seem to be setting a few variables that aren't being used for anything. Can you trim down your code sample to show what is actually important to what you are trying to accomplish?
Jul 12, 2014 at 2:11 answer added S McCrohan timeline score: 6
Jul 12, 2014 at 2:05 comment added Josh Smeaton I would rethink your strategy if possible. You don't really mention why you're caching objects, but I would imagine that if you needed to cache different Types, that the caller requesting an item from the cache would know what type it expects, and could cast appropriately. Save objects into a Dictionary<string, object>(), and retrieve with a (ExpectedType)cache.Get("key_name"). I may be way off the mark though which is why this is a comment.
Jul 12, 2014 at 0:52 comment added JohnLBevan propertyName, propertyValue, propertyType, propertyTypeName & cacheStatus are assigned to but never used; get rid of them and you'll get some performance gain.
Jul 12, 2014 at 0:35 comment added Ben Voigt Reflection is slow. Make sure you never use Reflection more than once for the same data. Use a Dictionary or something to store results, so you can do a lookup and avoid using reflection again.
Jul 12, 2014 at 0:32 history asked Amir Movahedi CC BY-SA 3.0