写过ASP组件的朋友来看看,谢谢(100分)

D

devecom

Unregistered / Unconfirmed
GUEST, unregistred user!
由于项目需要用到asp组件,但是我对这个不太了解,有一个问题想问问各位:
我要设计2个接口,每个接口公布自己的属性和方法,但是其中一个接口属于另外一个
的一部分,类似类中的一个继承,我表达好像不是和明确,应该能够理解吧。我应该怎么设计呢?
办法一:没通过
因为接口可以支持多重继承,我就像做成多重继承的方法,如:
Ttest = class(TASPObject, Itest)
private
x : integer;
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
function Get_wr: Integer
safecall;
procedure Set_wr(Value: Integer)
safecall;
public
procedure initialize;override

end;
....
function Ttest.Get_wr: Integer;
begin
result := x;
end;

procedure Ttest.Set_wr(Value: Integer);
begin
x := value;
end;

procedure Ttest.initialize;
begin
inherited;
x := 0;
Set_wr(20);
end;
调用这个接口的 Get_wr方法将会返回20.
另外一个接口类继承自它:
TChildTest := class(TASPObject,IChildTest,Itest)
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
public
end;
继承之后我应该怎么才能访问 Ttest中的 Get_wr方法呢?
方法二:我在TChildTest中定义一个成员,把TTest作为TChildTest的一个成员:
TChildtest = class(TASPObject, IChildtest)
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
public
CT : Ttest

procedure initialize;override;
destructor destroy;override;
end;

implementation

uses ComServ

destructor TChildtest.destroy;
begin
if Assigned(CT) then
Ct.Free;
inherited;
end;

procedure TChildtest.initialize;
begin
inherited;
CT := TTest.Create;
end;
。。。
但是这样我在asp中连对象都无法创建
服务器对象 错误 'ASP 0177 : 80040111'

Server.CreateObject 失败

/childtest.asp,行8

ClassFactory 无法供应请求的类别

这中问题对于高手应该不难吧?帮忙回答一下,有什么好的方法,谢谢。
 
怎么没人看啊?
 
采用第一种方法估计有点困难
因为 IChildTest继承了Itest接口,就要实现Itest接口的所有方法

只有第二种,CT作为TChildTest的一个成员有错吗?
 
还有,CT可能是一个TTest动态数组
CT : array of TTest;
这样更麻烦,用 TList解决更方便吗,定义一个record?
 
我的概念弄错了,接口不能像类一样初始化等操作

我的意思是设计2个接口,每个接口的实现类公布有自己的方法和属性,我所希望实现的就是
在asp能通过接口1访问另外一个接口,比如有2个接口类 AA,BB,BB有Get_name方法,我希望
在asp中:
set DelphiASPObj = Server.CreateObject("project1.AA")
后可以这样:
AA.BB.Get_name
访问,我看 ADODB好像是可以这样的,它可以通过 ADOConnection的Open方法产生一个
ADODataset对象.
大虾看看怎么实现:
 
我来看了。帮你一起研究,可能……
 
大家怎么了?
 
估计不能实现
 
建议您买一本<<ASP超级培训班>>看一看,里面有编写组件的详细介绍。
也可以到我的网站上下载电子书籍。
http://wangboys.126.com
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
714
import
I
I
回复
0
查看
681
import
I
顶部