You've already forked lazarus-ccr
TPublishedPropertyManager can now (if desired) handle unknown properties
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2378 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -29,6 +29,9 @@ Type
|
|||||||
TPublishedPropertyManager = class(TInterfacedObject,IPropertyManager)
|
TPublishedPropertyManager = class(TInterfacedObject,IPropertyManager)
|
||||||
Private
|
Private
|
||||||
FParent : TObject;
|
FParent : TObject;
|
||||||
|
FUnknownProps : IPropertyManager;
|
||||||
|
FHandleUnknownProps : Boolean;
|
||||||
|
private
|
||||||
procedure Error(Const AMsg:string);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
procedure Error(Const AMsg:string);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
procedure Error(Const AMsg:string; Const AArgs : array of const);overload;
|
procedure Error(Const AMsg:string; Const AArgs : array of const);overload;
|
||||||
Protected
|
Protected
|
||||||
@@ -39,7 +42,10 @@ Type
|
|||||||
procedure Clear();
|
procedure Clear();
|
||||||
procedure Copy(ASource:IPropertyManager; Const AClearBefore : Boolean);
|
procedure Copy(ASource:IPropertyManager; Const AClearBefore : Boolean);
|
||||||
Public
|
Public
|
||||||
constructor Create(AParent : TObject);
|
constructor Create(
|
||||||
|
AParent : TObject;
|
||||||
|
const AHandleUnknownProps : Boolean = False
|
||||||
|
);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
function IsStrEmpty(Const AStr:String):Boolean;{$IFDEF USE_INLINE}inline;{$ENDIF}overload;
|
function IsStrEmpty(Const AStr:String):Boolean;{$IFDEF USE_INLINE}inline;{$ENDIF}overload;
|
||||||
@@ -209,7 +215,8 @@ Var
|
|||||||
int64Val : Int64;
|
int64Val : Int64;
|
||||||
begin
|
begin
|
||||||
pinf := GetPropInfo(FParent,AName);
|
pinf := GetPropInfo(FParent,AName);
|
||||||
If Assigned(pinf) And Assigned(pinf^.SetProc) Then Begin
|
if Assigned(pinf) then begin
|
||||||
|
if Assigned(pinf^.SetProc) then begin
|
||||||
Case pinf^.PropType^.Kind of
|
Case pinf^.PropType^.Kind of
|
||||||
tkLString
|
tkLString
|
||||||
{$IFDEF WST_DELPHI},tkString{$ENDIF}
|
{$IFDEF WST_DELPHI},tkString{$ENDIF}
|
||||||
@@ -229,7 +236,10 @@ begin
|
|||||||
SetOrdProp(FParent,AName,Ord(StrToBool(AValue)));
|
SetOrdProp(FParent,AName,Ord(StrToBool(AValue)));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
End;
|
End;
|
||||||
End;
|
end;
|
||||||
|
end else if FHandleUnknownProps then begin
|
||||||
|
FUnknownProps.SetProperty(AName,AValue);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPublishedPropertyManager.SetProperties(const APropsStr: string);
|
procedure TPublishedPropertyManager.SetProperties(const APropsStr: string);
|
||||||
@@ -257,7 +267,8 @@ Var
|
|||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
pinf := GetPropInfo(FParent,AName);
|
pinf := GetPropInfo(FParent,AName);
|
||||||
If Assigned(pinf) And Assigned(pinf^.SetProc) Then Begin
|
if Assigned(pinf) then begin
|
||||||
|
if Assigned(pinf^.SetProc) then begin
|
||||||
Case pinf^.PropType^.Kind of
|
Case pinf^.PropType^.Kind of
|
||||||
tkLString
|
tkLString
|
||||||
{$IFDEF WST_DELPHI},tkString{$ENDIF}
|
{$IFDEF WST_DELPHI},tkString{$ENDIF}
|
||||||
@@ -270,7 +281,10 @@ begin
|
|||||||
tkInteger,tkInt64{$IFDEF FPC},tkQWord{$ENDIF} :
|
tkInteger,tkInt64{$IFDEF FPC},tkQWord{$ENDIF} :
|
||||||
Result := IntToStr(GetOrdProp(FParent,pinf));
|
Result := IntToStr(GetOrdProp(FParent,pinf));
|
||||||
End;
|
End;
|
||||||
End;
|
end;
|
||||||
|
end else if FHandleUnknownProps then begin
|
||||||
|
Result := FUnknownProps.GetProperty(AName);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPublishedPropertyManager.GetPropertyNames(ADest: TStrings): Integer;
|
function TPublishedPropertyManager.GetPropertyNames(ADest: TStrings): Integer;
|
||||||
@@ -279,6 +293,8 @@ Var
|
|||||||
i, propListLen : Integer;
|
i, propListLen : Integer;
|
||||||
begin
|
begin
|
||||||
ADest.Clear();
|
ADest.Clear();
|
||||||
|
if FHandleUnknownProps then
|
||||||
|
FUnknownProps.GetPropertyNames(ADest);
|
||||||
propListLen := GetPropList(PTypeInfo(FParent.ClassInfo),propList);
|
propListLen := GetPropList(PTypeInfo(FParent.ClassInfo),propList);
|
||||||
if (propListLen > 0) then begin
|
if (propListLen > 0) then begin
|
||||||
Try
|
Try
|
||||||
@@ -329,10 +345,16 @@ begin
|
|||||||
End;
|
End;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TPublishedPropertyManager.Create(AParent: TObject);
|
constructor TPublishedPropertyManager.Create(
|
||||||
|
AParent : TObject;
|
||||||
|
const AHandleUnknownProps : Boolean = False
|
||||||
|
);
|
||||||
begin
|
begin
|
||||||
Assert(Assigned(AParent));
|
Assert(Assigned(AParent));
|
||||||
FParent := AParent;
|
FParent := AParent;
|
||||||
|
FHandleUnknownProps := AHandleUnknownProps;
|
||||||
|
if FHandleUnknownProps then
|
||||||
|
FUnknownProps := TStoredPropertyManager.Create() as IPropertyManager;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user