i read your answer in the italian forum - with a little help of Google - about Extensions. I´ve tested it with a Vulcan class and i´m impressed how seamless it works ! Sure, you can´t access class vars, but better that route than no way to go
BEGIN NAMESPACE ControlExtensions
STATIC CLASS TabcontrolExtensions
STATIC METHOD GetAllControlsFromPage( SELF o AS Tabcontrol, iIndex AS INT ) AS ARRAY
LOCAL symPage AS SYMBOL
IF ( symPage := o:__GetSymbolFromIndex( iIndex - 1 )) != NULL_SYMBOL
RETURN o:GetAllControlsFromPage( symPage )
ELSE
RETURN {}
ENDIF
STATIC METHOD GetAllControlsFromPage( SELF o AS Tabcontrol, symPage AS SYMBOL ) AS ARRAY
LOCAL oWin AS Window
IF ( oWin := (Window) o:GetTabPage( symPage ) ) != NULL_OBJECT
RETURN oWin:GetAllChildren()
ELSE
RETURN {}
ENDIF
END CLASS
END NAMESPACE
static class StringExtensions
static method IsDigitsOnly( self cString as string ) as logic
local lReturn as logic
lReturn := true
foreach cChar as Char in cString
if cChar < '0' .or. cChar > '9'
lReturn := false
exit
endif
next
return lReturn
static method IsDecimalDigitsOnly( self cString as string ) as logic
local lReturn as logic
lReturn := true
foreach cChar as Char in cString
if ( cChar < '0' .or. cChar > '9' ) .and. ! cChar == '.' .and. ! cChar == ','
lReturn := false
exit
endif
next
return lReturn
end class
I have extended several base classes, not only string, but also object:
class ObjectExtensions
static method PropertyNames( self oObject as object ) as string[]
local aReturn as string[]
local nLen as int
local nI as int
local oProperties as System.Reflection.PropertyInfo[]
oProperties := oObject:GetType():GetProperties()
nLen := oProperties:Length
aReturn := string[]{nLen}
for nI := 1 upto nLen
aReturn[nI] := oProperties[nI]:Name
next
oProperties := null_object
return aReturn
end class
It is a very powerful possibility, and for sure you will find some of these extension methods also in the XSharp Tools library.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it