pascalabcnet/TestSuite/property4.pas

47 lines
1 KiB
ObjectPascal
Raw Permalink Normal View History

2017-08-08 19:33:17 +03:00
{$reference 'PresentationFramework.dll'}
{$reference 'WindowsBase.dll'}
{$reference 'PresentationCore.dll'}
{$reference 'WindowsFormsIntegration.dll'}
{$apptype windows}
uses System.Windows;
uses System.Windows.Media;
type
MyVisualHostBase = class(FrameworkElement)
public function getCnt: integer;
begin
Result := VisualChildrenCount;
end;
end;
MyVisualHost = class(MyVisualHostBase)
function getVisualChildrenCount: integer;
begin
Result := 1;
end;
protected property VisualChildrenCount: integer read getVisualChildrenCount; override;
end;
2017-08-08 23:00:19 +03:00
TBaseClass = class
function getA: integer;
begin
Result := 1;
end;
public property A: integer read getA; virtual;
end;
TDerClass = class(TBaseClass)
function getA: integer;
begin
Result := 2;
end;
public property A: integer read getA; override;
end;
2017-08-08 19:33:17 +03:00
begin
var obj: MyVisualHostBase := new MyVisualHost;
assert(obj.getCnt=1);
2017-08-08 23:00:19 +03:00
var obj2: TBaseClass := new TDerClass;
assert(obj2.A = 2);
2017-08-08 19:33:17 +03:00
end.