Question about the PropertyInfoQuestion about the PropertyInfo
Old forum URL: forums.lhotka.net/forums/t/7491.aspx
Eric_a posted on Friday, August 21, 2009
I was just wondering if I have to declare all of my PropertyInfo's as static? I tried it as non-static and it appeared to work alright. Is there any advantage to be had by declaring them as static vs. non-static? Thanks.
rxelizondo replied on Friday, August 21, 2009
Interesting, have you tried to create two instanced of the class where you declared the PropertyInfo’s as non-static variables?
If so, do you not get an error?JoeFallon1 replied on Tuesday, August 25, 2009
I imagine that the amount of memory consumed increases dramatically using instance variables instead of static ones. The static ones are re-used for every instance.
Joe
rxelizondo replied on Wednesday, August 26, 2009
JoeFallon1: I imagine that the amount of memory consumed increases dramatically using instance variables instead of static ones. The static ones are re-used for every instance.
Joe
I tested this using instance PropertyInfos and I get an error, I don’t think the CSLA is designed to allow instance PrepertyInfos.
Perhaps I am missing something here, were you able to compile and run a class using instance PropertyInfos and create *two* instance of your custom class?
Thanks
RockfordLhotka replied on Wednesday, August 26, 2009
It is absolutely NOT designed to work with instance-level definitions. Maybe you could make it work if you figure out a way for RegisterProperty() to be called exactly once per type per AppDomain (which is what happens with the static fields), but otherwise who know what nasty stuff will happen.
Why would you want to take the perf and memory hit of having these be instance level anyway?
rfcdejong replied on Wednesday, August 26, 2009
The fieldmanager throws an exception when u try to register properties after an instance is created, so it should not even be possible to register an property at instance level. It's strange that u can.
Dynamic properties is another thing, they can be differend in another case.Copyright (c) Marimer LLC