473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Serialize using an interface?

Hi,
I have an two classes derived from ICommand interface

for example SubscribeCommand,and RetryCommand

i want to do the following

ICommand command1=new SubscribeCommand()

ICommand command2=new RetryCommand()

Now i want to

Serialize

both command1 and command2 to a string

is it possible?

thanks.


Nov 16 '05 #1
3 1459
Hi Julia,

It will be possible only if classes SubscriberCommand
and RetryCommand support serialization (e.g. ICommand
inherits ISerializable).

What do you mean: serialize to a string?

Cheers!

Marcin
Hi,
I have an two classes derived from ICommand interface

for example SubscribeCommand,and RetryCommand

i want to do the following

ICommand command1=new SubscribeCommand()

ICommand command2=new RetryCommand()

Now i want to

Serialize

both command1 and command2 to a string

is it possible?

thanks.

Nov 16 '05 #2
Why should I derive from ISerializable?

I was thinking that GetType() will return ICommand but it returning the
derived class type
(the one I need) so wouldn't it work as an ordinary serialization?

thanks
"Marcin Grzębski" <mg*******@taxussi.no.com.spam.pl> wrote in message
news:ch**********@atlantis.news.tpi.pl...
Hi Julia,

It will be possible only if classes SubscriberCommand
and RetryCommand support serialization (e.g. ICommand
inherits ISerializable).

What do you mean: serialize to a string?

Cheers!

Marcin
Hi,
I have an two classes derived from ICommand interface

for example SubscribeCommand,and RetryCommand

i want to do the following

ICommand command1=new SubscribeCommand()

ICommand command2=new RetryCommand()

Now i want to

Serialize

both command1 and command2 to a string

is it possible?

thanks.

Nov 16 '05 #3
If you declare both classes as [Serialize()] as well as the structs in
the classes etc, then you should be able to. Also you need to make
sure that SubscribeCommand and RetryCommand extend ICommand.
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
1
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
3
by: Pol Bawin | last post by:
A class has a private field of type IWizard (An interface) and a public property to access it. When I try to serialize the Geometry class in XML, i have an error but it works in Binary Can...
1
by: n_o_s_p_a__m | last post by:
My web service has a webmethod whose return type is declared as an interface type, for example: public IBusinessProcess GetBusinessProcess() {} which generates the lovely error: Cannot...
1
by: Roberto Carriquiry | last post by:
I am writeing a webService that needs to recieve a CDO.Person object as a parameter. but when I run it I have a runtime error. Cannot serialize member CDO.PersonClass.DataSource of type...
2
by: films | last post by:
I understand the concept. Serialization of a class will add all the sub-objects of the class to the stream if there are also serializible. So say I have: class Author {
7
by: Ben Amada | last post by:
I've created a class that I need to store in ViewState. However when I try to store it in ViewState, I get the following error: "The type 'solution.pe2' must be marked as Serializable or have a...
3
by: Julie | last post by:
Here's the scenario (public attributes, etc. omitted for brevity): class Base { } class Derived : Base { }
2
by: =?Utf-8?B?U2hhd24=?= | last post by:
Hi; I would like to be able to use the XMLSerializer to serialize and deserialize a dictionary. is that possible? i know that you can serialize an object that implements the ICollection interface....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.