Using the Delphi Spring framework, is it possible to register a generic type with GlobalContainter? I am trying to do something like this:
TMyBaseType = class
protected
FName: string;
function GetName: string; virtual;
procedure SetName(Value: string); virtual;
public
property Name: string read GetName write SetName;
end;
TMyFirstThing = class(TMyBaseType)
protected
function GetName: string; override;
end;
TMySecondThing = class(TMyBaseType)
protected
procedure SetName(Value: string); override;
end;
TMyGenericType<T: TMyBaseType> = class
public
procedure DoSomethingWithIt(AObject: T);
function GetTheSomethingsName(AObject: T): string;
end;
......
initialization
GlobalContainer.RegisterType<TMyGenericType<>>;
I'm not sure if what I'm trying to do is possible or is there a better / alternative way to do this? I am using Delphi 2010 with the latest Spring4D platform. (I also have Delphi XE5, but the project itself is still 2010 due to third-party libraries). Any ideas or suggestions would be most appreciated.
source
share