最近我发现Delphi对象检查器以灰色显示一些属性.这是一个例子:

我想知道它是什么意思?如何定义这些属性?我没有发现让我们说DSHostname和ProxyHost的定义有任何不同.但正如您所见,DSHostname正常显示,ProxyHost显示为灰色.
以下是相关财产的相关声明:
/// <summary>The host to proxy requests through, or empty string to not use a proxy.</summary>
property ProxyHost: string read FProxyHost write FProxyHost;
/// <summary>The port on the proxy host to proxy requests through. Ignored if DSProxyHost isn't set.
/// </summary>
[Default(8888)]
property ProxyPort: Integer read FProxyPort write FProxyPort default 8888;
/// <summary>The user name for authentication with the specified proxy.</summary>
property ProxyUsername: string read FProxyUsername write FProxyUsername;
/// <summary>The password for authentication with the specified proxy.</summary>
property ProxyPassword: string read FProxyPassword write FProxyPassword;
Run Code Online (Sandbox Code Playgroud)
最后,我得到了一个证据,证明Remy Lebeau的猜测正确.我做了TDSClientCallbackChannelManager的后代,它已经发布了属性TestProxyHost.此属性除了在Get和Set中镜像ProxyHost之外什么都不做.以下是组件的完整代码:
unit uTestCallbackChannelManager;
interface
uses
System.SysUtils, System.Classes, Datasnap.DSCommon;
type
TTestCallbackChannelManager = class(TDSClientCallbackChannelManager)
private
function GetTestProxyHost: string;
procedure SetTestProxyHost(const Value: string);
published
property TestProxyHost: string read GetTestProxyHost write SetTestProxyHost;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TTestCallbackChannelManager]);
end;
{ TTestCallbackChannelManager }
function TTestCallbackChannelManager.GetTestProxyHost: string;
begin
Result := ProxyHost;
end;
procedure TTestCallbackChannelManager.SetTestProxyHost(const Value: string);
begin
ProxyHost := Value;
end;
end.
Run Code Online (Sandbox Code Playgroud)
在我将TTestCallbackChannelManager安装到组件面板后,我将其放入测试项目中的表单上.
在Object Inspector中,ProxyHost属性显示为灰色,TestProxyHost正常显示.现在,如果我更改TestProxyHost,那么也会更改ProxyHost.这是一个截图:
这意味着:
唯一的问题是属性编辑器背后的逻辑是什么?当属性可用时以及如何使用它们?看起来这些属性最近在xe10或更早版本中引入.Embarcadero没有提供有关这些属性的文档(至少目前我找不到任何文档).但这是一个单独问题的主题.我怀疑对这些属性的支持尚未经过测试(或可能尚未实现),因此它们旨在用于将来的版本中.
| 归档时间: |
|
| 查看次数: |
476 次 |
| 最近记录: |