1 Star 1 Fork 1

大量/QuickCore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Quick.Core.Extensions.FormFactory.pas 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
Exilon 提交于 2021-05-17 16:07 +08:00 . [ioc] Form Factory extension
unit Quick.Core.Extensions.FormFactory;
interface
uses
System.SysUtils,
{$IFDEF VCL}
Vcl.Forms,
{$ELSE}
Fmx.Forms,
{$ENDIF}
Quick.Core.DependencyInjection;
type
TFormFactoryServiceExtension = class(TServiceCollectionExtension)
class function AddFormFactory : TServiceCollection;
end;
TFormFactory = class
var
fServiceCollection : TServiceCollection;
public
constructor Create(aServiceCollection : TServiceCollection);
function New<T : TForm, constructor> : T;
end;
implementation
{ TFormFactoryServiceExtension }
class function TFormFactoryServiceExtension.AddFormFactory : TServiceCollection;
begin
Result := ServiceCollection;
Result.AddSingleton<TFormFactory>('',function : TFormFactory
begin
Result := TFormFactory.Create(ServiceCollection);
end);
end;
{ TFormFactory }
constructor TFormFactory.Create(aServiceCollection: TServiceCollection);
begin
fServiceCollection := aServiceCollection;
end;
function TFormFactory.New<T>: T;
begin
Result := fServiceCollection.AbstractFactory<T>;
end;
end.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wzdlsoft/QuickCore.git
git@gitee.com:wzdlsoft/QuickCore.git
wzdlsoft
QuickCore
QuickCore
master

搜索帮助