I need to get a property or anyway to set my private variable that is used within the property's accessor.
example:
Expand|Select|Wrap|Line Numbers
- public class Fluffers{
- public FooBar Foo{
- get{
- if (pFoo == null)
- StaticFunction.Link((pFoo = new FooBar()));
- return pFoo;
- }
- set{
- StaticFunction.ReLink(value, pFoo);
- pFoo = value;
- }
- }
- private FooBar pFoo = null;
- }
but, now I need to set pFoo on other parts of the software, I just can't get a good way to do this in an easy way
the way I thought is:
change the Link(var)
to Link(var, string PropertyName, object OwnerObjectOfTheProperty
and through reflection use PropertyInfo to set it with SetValue
that may work, but I wouldn't like to have to type the property name everytime, its a little lame, see:
Expand|Select|Wrap|Line Numbers
- public FooBar Foo{
- get{
- if (pFoo == null)
- StaticFunction.Link((pFoo = new FooBar()), "Foo", this);
- return pFoo;
- }
- set{
- StaticFunction.ReLink(value, pFoo);
- pFoo = value;
- }
- }
- private FooBar pFoo = null;
maybe passing Foo as a propertyinfo, or delegate or whatever
any help plz?
( a preprocessor macro would do this so easy, wouldn't it =[ )
Thanks!
Joe