我有以下代码:
for i := 0 to FControlList.Count - 1 do
if Supports(IMyControl(FControlList[i]), IMyControlEx) then
begin
MyControlEx := IMyControl(FControlList[i]) as IMyControlEx;
MyControlEx.DoYourMagic(Self, SomeData);
end;
Run Code Online (Sandbox Code Playgroud)
在我的应用程序执行期间多次调用此代码,但在某些特定情况下,它在Supports()方法中失败.更具体地说 - 它似乎属于Supports()方法中的QueryInterface()调用.
我检查了FControlList不是nil而FControlList [i]不是nil并且它仍然发生.
任何想法将不胜感激!
有一个外部Web服务,分别要求客户端给他.基于shell Embarcadero的WSDL标准RAD Studio XE(Delphi XE)创建了一个通常运行良好的单元,但在这种情况下有一个警告 - 其中一个函数转移到100多个参数.当您在运行时创建用于调用Web服务的对象时,会收到错误"方法'方法名称中的参数太多'".如果参数的数量减少到61,那么一切都开始工作 - 调用Web服务运行正常并返回响应.为什么会这样?转向互联网,但结果为零.
我有两个关系为1-n的课程.像这样:
class Band
include Mongoid::Document
has_many :members
end
class Member
include Mongoid::Document
field :name, type: String
field :joined, type: Date
belongs_to :band
end
Run Code Online (Sandbox Code Playgroud)
现在,当我打电话时,band.members我得到了成员对象.我想要的是,如果我打电话band.members.last来获得加入最后一个的成员.我通过定义基于以下的<=>方法Member和排序来实现这一点joined:
band.members.sort.last
Run Code Online (Sandbox Code Playgroud)
如何将此行为设为默认值?我不想避免额外的排序调用.这是可能的,如果可以,怎么样?
这是我的类型......
unit unitTestInterfaces;
interface
type
IFoo = interface
['{169AF568-4568-429A-A8F6-C69F4BBCC6F0}']
function TestFoo1:string;
function TestFoo:string;
end;
IBah = interface
['{C03E4E20-2D13-45E5-BBC6-9FDE12116F95}']
function TestBah:string;
function TestBah1:string;
end;
TFooBah = class(TInterfacedObject, IFoo, IBah)
//IFoo
function TestFoo1:string;
function TestFoo:string;
//IBah
function TestBah1:string;
function TestBah:string;
end;
implementation
{ TFooBah }
function TFooBah.TestBah: string;
begin
Result := 'TestBah';
end;
function TFooBah.TestBah1: string;
begin
Result := 'TestBah1';
end;
function TFooBah.TestFoo: string;
begin
Result := 'TestFoo';
end;
function TFooBah.TestFoo1: string;
begin
Result := 'TestFoo1';
end;
end.
Run Code Online (Sandbox Code Playgroud)
这是运行示例的代码...
var
fb:TFooBah;
f:IFoo; …Run Code Online (Sandbox Code Playgroud)