Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The creature that won't die
Message
From
25/03/2010 11:40:53
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
General information
Forum:
Visual FoxPro
Category:
VFP Compiler for .NET
Miscellaneous
Thread ID:
01456123
Message ID:
01457180
Views:
79
>>
LPARAMETERS toObj 
>>IF PEMSTATUS(toObj, "oGadget", 5)
>>	toObj.oengine=this.oGadget
>>ENDIF
      public void Doit(object toObj)
>       {
>           PropertyInfo pi = toObj.GetType().GetProperty("oengine");
>           if (pi != null)
>               pi.SetValue(toObj,oGadget,null);
>       }
>

Interesting separation... a property is an object, still related to its owner but you can operate on it all the same. A tad more complicated, but as long as it gets the job done, cool.
What's the null in the last line for? And, oGadget isn't defined... shouldn't it be a string literal?

>>
LPARAMETERS toObj
>>	IF toObj.BASECLASS="Timer"
>>		IF toObj.ENABLED AND toobj.interval>0
>>			toObj.ENABLED=.F.
>>			toObj.INTERVAL=0
>>		ENDIF
>>	ENDIF
>>
public void Doit (object toObj)
>        {
>            Timer t = toObj as Timer;
>            if (t != null)
>            {
>                if (t.Enabled && t.Interval > 0)
>                {
>                    t.Enabled = false;
>                    t.Interval = 0;
>                }
>            }
>        }
The AS operator is unintuitive but neat... implicit cast returning a null if it fails? Though, this sounds more like a try-catch "see if this works" code, instead of having an IsA(toObj, tcClass) function. What happens if you try to cast a twice subclassed timer as a timer, do you still get a reference to the original object?

>I'd do a bit more type checking in the first one if it was for production - but even as it stands it is safer than the VFP version...

And what's unsafe in it?

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform