2018-04-10 20:19:28 +03:00
|
|
|
|
type
|
|
|
|
|
|
ConceptAttribute = class(System.Attribute)
|
|
|
|
|
|
end;
|
|
|
|
|
|
IsConceptParameterAttribute = class(System.Attribute)
|
|
|
|
|
|
end;
|
|
|
|
|
|
ExplicitModelAttribute = class(System.Attribute)
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
[Concept] SumTC<T> = abstract class
|
|
|
|
|
|
public
|
|
|
|
|
|
function sum(v1, v2: T): T; abstract;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
SumTC_Integer = class(SumTC<integer>)
|
|
|
|
|
|
public
|
|
|
|
|
|
|
|
|
|
|
|
function sum(v1, v2: Integer): Integer; override;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := v1 + v2;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2018-04-25 19:54:24 +03:00
|
|
|
|
|
2018-04-20 12:03:38 +03:00
|
|
|
|
function Sum3<T, SumTCT>(v1, v2, v3: T): T; where SumTCT: SumTC<T>, constructor;
|
|
|
|
|
|
begin
|
2018-04-25 19:54:24 +03:00
|
|
|
|
var s := __ConceptSingleton&<SumTCT>.&Instance;
|
2018-04-20 12:03:38 +03:00
|
|
|
|
Result := s.sum(v1, s.sum(v2, v3));
|
|
|
|
|
|
end;
|
2018-04-25 19:54:24 +03:00
|
|
|
|
|
2018-04-10 20:19:28 +03:00
|
|
|
|
|
|
|
|
|
|
begin
|
2018-04-17 19:07:59 +03:00
|
|
|
|
write(Sum3&<integer, SumTC_integer>(1, 2, 3));
|
2018-04-10 20:19:28 +03:00
|
|
|
|
end.
|