I’m trying to use Shared Project with simple interface - IInpxTable.
Then I’ve a ClassLib Common with a reference to Shared and a class TInpxTable that implements IInpxTable.
The next ClassLib TestClassLib with a reference to Common ClaccLib, contains interface
IInpxTestTable = public interface(IInpxTable)
and a class
TInpxTestTable = public class(TInpxTable, IInpxTestTable)
It works, but when I add a reference in TestClassLib to Shared Project it fails to compile.
The question is - is it possible to use Shared Project in multiple projects or there should be only one project with a reference to shared and other project should have reference to it?
type
ItemAddedOrEditedEventHandler = public delegate;
IInpxTable = public interface
event AddedOrEdited: ItemAddedOrEditedEventHandler;
end;
Twice; once in Common (which implements it in TInpxTable) and once in TestClassLib which descends from that. Now you have TWO ItemAddedOrEditedEventHandler types, and they’re not compatible.
TInpxTable implements IInpxTable and have AddedOrEdited event.
Than TInpxTestTable inherits from TInpxTable where AddedOrEdited is implemented but it seems that complier don’t see it.
I’ve added
IInpxtable2 = public interface(IInpxTable)
event AddedOrEdited: ItemAddedOrEditedEventHandler;
end;
and changed
TInpxTable = public class(IInpxtable2)
private
protected
public
event AddedOrEdited: ItemAddedOrEditedEventHandler;
end;
than
IInpxTestTable = public interface(IInpxTable)
end;
and
TInpxTestTable = public class(TInpxTable, IInpxTestTable)
end;
and everyting works fine.
Why without shared project it works different? I don’t uderstand why ‘TWICE’ - it inherits and shuldn’t be TWICE.
You use shared projects. They’re not the same as libraries but they get included in each project seperately. So you have two copies of both ItemAddedOrEditedEventHandler and IInpxTable, which is causing this.
I want to use Shared Project to include there my interfaces. Than on each platform I would like to create Class Library with implementation of those shared interfaces.
You can, what you can’t do is have it included in two projects that use eachother on the same platform. Every type is unique identified both by the library it’s in and the type name.