I need to add some functionality to the TObjectArray class in the XSuperObject library. I could just add it directly into the source code in XSuperObject.pas, but that's not how I should do it. Instead I want to derive my own interface+class from the ISuperArray/TSuperArray pair. But how? I know how to derive a class on its own, but I've never done it before when interfaces are involved.
XSuperObject.pas defines these classes as follows:
type
ISuperArray = interface(IBaseJSON<IJSONArray, Integer>)
['{41A2D578-CFAB-4924-8F15-0D0227F35412}']
...
end;
TSuperArray = class(TBaseJSON<IJSONArray, Integer>, ISuperArray)
...
end;
What I would like to do is this:
uses
...
xsuperobject;
type
TProductJson = class(TSuperArray)
CategoryIndex: integer;
SubcategoryIndex: integer;
constructor Create(JSON: String);
procedure AddCategory(Title: string);
procedure AddSubcategory(Title: string);
end;
Or should I also derive from the interface at the same time? Maybe something like this?
uses
...
xsuperobject;
type
IProductJson = interface(ISuperArray)
end;
TProductJson = class(TSuperArray, IProductJson)
CategoryIndex: integer;
SubcategoryIndex: integer;
constructor Create(JSON: String);
procedure AddCategory(Title: string);
procedure AddSubcategory(Title: string);
end;
So my question is: how do I properly derive my own class/interface from ISuperArray/TSuperArray?
And if I must derive from the interface as well, do I also need to duplicate the GUID, or create a new GUID, or drop the GUID?
And the second question: XSuperObject.pas defines 2 functions: SO and SA, to initialize a SuperObject resp. SuperArray.
Will the SA function remain compatible with my derived interface/class? Or will it not be assignment compatible after I have derived from it?
(maybe a typecast could help there?)