45 lines
615 B
Plaintext
45 lines
615 B
Plaintext
class DelegateA 'not implmenting thing()
|
|
'==============
|
|
'
|
|
string message
|
|
|
|
end class
|
|
|
|
class DelegateB 'implementing thing()
|
|
'==============
|
|
'
|
|
string message
|
|
|
|
method thing() as string
|
|
return message
|
|
end method
|
|
'
|
|
end class
|
|
|
|
|
|
Class Delegator
|
|
'==============
|
|
'
|
|
has DelegateA dgA
|
|
has DelegateB dgB
|
|
'
|
|
method operation() as DelegateB
|
|
dgB.message="Delegate Implementation"
|
|
return @dgB
|
|
end method
|
|
|
|
method thing() as string
|
|
return "not using Delegate"
|
|
end method
|
|
'
|
|
end class
|
|
|
|
'====
|
|
'TEST
|
|
'====
|
|
|
|
Delegator dgr
|
|
let dg=dgr.operation
|
|
print dgr.thing 'result "not using Delegate"
|
|
print dg.thing 'result "Delegate Implementation"
|