2
0
Эх сурвалжийг харах

Merge branch 'master' of https://github.com/exilon/QuickLib

Exilon 10 сар өмнө
parent
commit
69727a18cf

+ 2 - 2
Quick.Console.pas

@@ -943,7 +943,7 @@ begin
   {$IFDEF DELPHIXE7_UP}
   {$IFDEF DELPHIXE7_UP}
   fConsoleMenu := fConsoleMenu + [conmenu];
   fConsoleMenu := fConsoleMenu + [conmenu];
   {$ELSE}
   {$ELSE}
-  SetLength(fConsoleMenu,High(fConsoleMenu)+1);
+  SetLength(fConsoleMenu,Length(fConsoleMenu)+1);
   fConsoleMenu[High(fConsoleMenu)] := conmenu;
   fConsoleMenu[High(fConsoleMenu)] := conmenu;
   {$ENDIF}
   {$ENDIF}
 end;
 end;
@@ -953,7 +953,7 @@ begin
   {$IFDEF DELPHIXE7_UP}
   {$IFDEF DELPHIXE7_UP}
   fConsoleMenu := fConsoleMenu + [MenuOption];
   fConsoleMenu := fConsoleMenu + [MenuOption];
   {$ELSE}
   {$ELSE}
-  SetLength(fConsoleMenu,High(fConsoleMenu)+1);
+  SetLength(fConsoleMenu,Length(fConsoleMenu)+1);
   fConsoleMenu[High(fConsoleMenu)] := MenuOption;
   fConsoleMenu[High(fConsoleMenu)] := MenuOption;
   {$ENDIF}
   {$ENDIF}
 end;
 end;

+ 28 - 1
Quick.IOC.pas

@@ -223,6 +223,14 @@ type
     class function TryToGetService<T: IInterface>(aService : T) : Boolean;
     class function TryToGetService<T: IInterface>(aService : T) : Boolean;
   end;
   end;
 
 
+  Name = class(TCustomAttribute)
+  private
+    fName: string;
+  public
+    constructor Create(aName: string);
+    property Name: String read fName;
+  end;
+
   EIocRegisterError = class(Exception);
   EIocRegisterError = class(Exception);
   EIocResolverError = class(Exception);
   EIocResolverError = class(Exception);
   EIocBuildError = class(Exception);
   EIocBuildError = class(Exception);
@@ -609,6 +617,8 @@ var
   rParam : TRttiParameter;
   rParam : TRttiParameter;
   value : TValue;
   value : TValue;
   values : TArray<TValue>;
   values : TArray<TValue>;
+  att: TCustomAttribute;
+  attname: string;
 begin
 begin
   Result := nil;
   Result := nil;
   rtype := ctx.GetType(aClass);
   rtype := ctx.GetType(aClass);
@@ -627,7 +637,17 @@ begin
       begin
       begin
         for rParam in rmethod.GetParameters do
         for rParam in rmethod.GetParameters do
         begin
         begin
-          value := Resolve(rParam.ParamType.Handle);
+          attname := EmptyStr;
+          for att in rParam.GetAttributes do
+          begin
+            if att is Name then
+            begin
+              attname := Name(att).Name;
+              Break;
+            end;
+          end;
+
+          value := Resolve(rParam.ParamType.Handle, attname);
           values := values + [value];
           values := values + [value];
         end;
         end;
         Result := rmethod.Invoke(TRttiInstanceType(rtype).MetaclassType,values);
         Result := rmethod.Invoke(TRttiInstanceType(rtype).MetaclassType,values);
@@ -816,4 +836,11 @@ begin
   Result := fResolver.CreateInstance(TClass(TImplementation)).AsType<TInterface>;
   Result := fResolver.CreateInstance(TClass(TImplementation)).AsType<TInterface>;
 end;
 end;
 
 
+{ Name }
+constructor Name.Create(aName: string);
+begin
+  fName := aName;
+end;
+
+
 end.
 end.

+ 1 - 0
Quick.RTTI.Utils.pas

@@ -88,6 +88,7 @@ var
   rmethod: TRttiMethod;
   rmethod: TRttiMethod;
   rinstype: TRttiInstanceType;
   rinstype: TRttiInstanceType;
 begin
 begin
+  Result := Default(T);
   rtype := fCtx.GetType(TypeInfo(T));
   rtype := fCtx.GetType(TypeInfo(T));
   for rmethod in rtype.GetMethods do
   for rmethod in rtype.GetMethods do
   begin
   begin

+ 1 - 1
Quick.Threads.pas

@@ -685,7 +685,7 @@ begin
   try
   try
     for obj in FQueue do
     for obj in FQueue do
     begin
     begin
-      if TypeInfo(T) = TypeInfo(TObject) then PObject(@obj){$IFNDEF FPC}.DisposeOf;{$ELSE}.Free;{$ENDIF}
+      if TypeInfo(T) = TypeInfo(TObject) then PObject(@obj){$ifndef FPC}{$IFDEF  DELPHIRX12_UP}.Free{$ELSE}.DisposeOf{$ENDIF}{$ELSE}.Free{$ENDIF};
     end;
     end;
 
 
     SetLength(FQueue,0);
     SetLength(FQueue,0);