@@ -425,6 +425,7 @@ procedure TOptionsContainer.Save;
425
425
fSerializer.Save(fFilename,fSections);
426
426
finally
427
427
// set last state
428
+ Sleep(0 );
428
429
fFileMonitor.Enabled := laststate;
429
430
end ;
430
431
end
@@ -494,33 +495,28 @@ procedure TOptionsValidator.ValidateObject(aObj : TObject);
494
495
attrib : TCustomAttribute;
495
496
rvalue : TValue;
496
497
begin
497
- ctx := TRttiContext.Create;
498
- try
499
- rtype := ctx.GetType(aObj.ClassInfo);
500
- for rprop in rtype.GetProperties do
498
+ rtype := ctx.GetType(aObj.ClassInfo);
499
+ for rprop in rtype.GetProperties do
500
+ begin
501
+ // check only published properties
502
+ if rprop.Visibility = TMemberVisibility.mvPublished then
501
503
begin
502
- // check only published properties
503
- if rprop.Visibility = TMemberVisibility.mvPublished then
504
+ // check validation option attributes
505
+ for attrib in rprop.GetAttributes do
504
506
begin
505
- // check validation option attributes
506
- for attrib in rprop.GetAttributes do
507
- begin
508
- if attrib is Required then ValidateRequired(aObj,rprop)
509
- else if attrib is StringLength then ValidateStringLength(aObj,rprop,StringLength(attrib))
510
- else if attrib is Range then ValidateRange(aObj,rprop,Range(attrib));
511
- end ;
512
- rvalue := rprop.GetValue(aObj);
513
- if not rvalue.IsEmpty then
514
- begin
515
- case rvalue.Kind of
516
- tkClass : ValidateObject(rvalue.AsObject);
517
- tkDynArray : ValidateArray(rvalue);
518
- end ;
507
+ if attrib is Required then ValidateRequired(aObj,rprop)
508
+ else if attrib is StringLength then ValidateStringLength(aObj,rprop,StringLength(attrib))
509
+ else if attrib is Range then ValidateRange(aObj,rprop,Range(attrib));
510
+ end ;
511
+ rvalue := rprop.GetValue(aObj);
512
+ if not rvalue.IsEmpty then
513
+ begin
514
+ case rvalue.Kind of
515
+ tkClass : ValidateObject(rvalue.AsObject);
516
+ tkDynArray : ValidateArray(rvalue);
519
517
end ;
520
518
end ;
521
519
end ;
522
- finally
523
- ctx.Free;
524
520
end ;
525
521
end ;
526
522
@@ -543,22 +539,17 @@ procedure TOptionsValidator.ValidateArray(aValue : TValue);
543
539
itvalue : TValue;
544
540
i : Integer;
545
541
begin
546
- ctx := TRttiContext.Create;
547
- try
548
- rDynArray := ctx.GetType(aValue.TypeInfo) as TRTTIDynamicArrayType;
549
- for i := 0 to aValue.GetArrayLength - 1 do
542
+ rDynArray := ctx.GetType(aValue.TypeInfo) as TRTTIDynamicArrayType;
543
+ for i := 0 to aValue.GetArrayLength - 1 do
544
+ begin
545
+ TValue.Make(PPByte(aValue.GetReferenceToRawData)^ + rDynArray.ElementType.TypeSize * i, rDynArray.ElementType.Handle,itvalue);
546
+ if not itvalue.IsEmpty then
550
547
begin
551
- TValue.Make(PPByte(aValue.GetReferenceToRawData)^ + rDynArray.ElementType.TypeSize * i, rDynArray.ElementType.Handle,itvalue);
552
- if not itvalue.IsEmpty then
553
- begin
554
- case itvalue.Kind of
555
- tkClass : ValidateObject(itvalue.AsObject);
556
- tkDynArray : ValidateArray(itvalue);
557
- end ;
548
+ case itvalue.Kind of
549
+ tkClass : ValidateObject(itvalue.AsObject);
550
+ tkDynArray : ValidateArray(itvalue);
558
551
end ;
559
552
end ;
560
- finally
561
- ctx.Free;
562
553
end ;
563
554
end ;
564
555
0 commit comments