Delphi 7 RemObjects-序列化组件 [英] Delphi 7 remobjects - serialize a component

查看:200
本文介绍了Delphi 7 RemObjects-序列化组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Delphi 7和RemObjects SDK构建的客户端服务器应用程序。客户端和服务器之间的消息是二进制的( http://wiki.remobjects.com/wiki/BinMessage )。我的问题是:
1)如果我用TDataSet / TDataSource填充数据并将其从客户端发送到服务器,服务器组件的DataSet上将包含数据吗?数据应该保持持久吗?
2)我试图通过封装在TROBinaryMemoryStream后代类中的RemObjects发送组件,但是没有成功

I have a client-server application built in Delphi 7 and RemObjects SDK. Messages between client and server are binary (http://wiki.remobjects.com/wiki/BinMessage). My questions are: 1) if I fill with data a TDataSet/TDataSource and sent them from client to server, on the server component's DataSet will contain the data? the data should remain persistent no? 2) I've tried to send the component through RemObjects, encapsulated in a TROBinaryMemoryStream descendant class, but without succes

类定义

  TRODataSource=class(TROBinaryMemoryStream)
   private
     FNameDS:String;
     FDS:TDataSource;
     procedure SetName(aValue:String);
     procedure SetDS(aValue:TDataSource);
  public
   published
    property Name:String read FNameDS write SetName;
    property DataSource:TDataSource read FDS write SetDS;
  end;

发送数据源的方法

function foo(aDataSource: TDataSource):integer;
var
  wStream:TRODataSource;
begin
 wStream:=TRODataSource.Create;
 wStream.Name:='TEST';
 wStream.DataSource:=aDataSource;
 try
  Result:=(RORemoteService as ISvc..).foo1(wstream);//method existing on the server will //return how many records are in the dataset
 finally
  freeandnil(wstream);
 end;
end;

任何答案都会被理解。

LE:似乎只有TROComplexType的类后代可以序列化 http://wiki.remobjects.com/wiki / Remote_Object_Allocation_and_Serialization 。但是我不确定是否不能序列化流上的组件。

LE: it seems that only classes descendants of the TROComplexType can be serialized http://wiki.remobjects.com/wiki/Remote_Object_Allocation_and_Serialization. But I'm not sure if I can not serialize a component on a stream.

推荐答案

当您将组件序列化为流时(请参阅我的另一篇文章),可以使用二进制类型来将流从服务器发送到客户端(并反向发送):
http://wiki.remobjects。 com / wiki / TROBinaryMemoryStream_Class

When you have your component serialized to a stream (see my other post), you can use the "Binary" type to send the stream from the server to client (and reverse): http://wiki.remobjects.com/wiki/TROBinaryMemoryStream_Class

或者只是将其作为字符串发送:-)。无需重写TROBinaryMemoryStream!

Or just send it as a string :-). No need to override TROBinaryMemoryStream!

这篇关于Delphi 7 RemObjects-序列化组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆