interface\r
\r
uses\r
- Generics.Collections;\r
+ Generics.Collections, TypInfo,\r
+ Thrift.Protocol;\r
\r
type\r
TFactoryMethod<T> = function:T;\r
class destructor Destroy;\r
class procedure RegisterTypeFactory<F>(const aFactoryMethod: TFactoryMethod<F>);\r
class function Construct<F>: F;\r
+ class function ConstructFromTypeInfo(const aTypeInfo: PTypeInfo): IBase;\r
end;\r
\r
implementation\r
\r
-uses\r
- TypInfo;\r
\r
{ TypeRegistration }\r
\r
end;\r
end;\r
\r
+class function TypeRegistry.ConstructFromTypeInfo(const aTypeInfo: PTypeInfo): IBase;\r
+var\r
+ Factory : Pointer;\r
+begin\r
+ Result := nil;\r
+ if FTypeInfoToFactoryLookup.TryGetValue(aTypeInfo, Factory)\r
+ then Result := IBase(TFactoryMethod<IBase>(Factory)());\r
+end;\r
+\r
+\r
+\r
\r
end.\r