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); > }>
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?