473,406 Members | 2,954 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,406 software developers and data experts.

Override Serializable attribute?

I have a class that I'm serializing to xml. To omit some properties
from the xml I use the [System.Xml.Serialization.XmlIgnore] attribute.

Now I'm thinking that sometimes I want to include those properties, so
I'm wondering if it's possible to inherit from the original class
overriding that attribute (or leave the attribute out of the base class
and put it in the inherited class).

(Note that I'm struggling with the ISerializable interface, and would
be happy to leave that out of the conversation).

TIA,
Jim

Nov 17 '05 #1
1 2969
Jim,

I am curious, you say you are struggling with the ISerializable
interface, but the XmlIgnore attribute has nothing to do with that interface
(XML serialization and serialization are two separate things).

That being said, I believe that the XmlIgnore attribute is an inherited
attribute. Because of that, you can't shut it off, so to speak.

What you need to do for xml serialization is implement the
IXmlSerializable interface, and you can handle the
serialization/deserialization of your class instances through that interface
(of course, you have to do all the work yourself).

You can do the same thing with serialization, by implementing
ISerializable and the custom serialization constructor.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<jh*****@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have a class that I'm serializing to xml. To omit some properties
from the xml I use the [System.Xml.Serialization.XmlIgnore] attribute.

Now I'm thinking that sometimes I want to include those properties, so
I'm wondering if it's possible to inherit from the original class
overriding that attribute (or leave the attribute out of the base class
and put it in the inherited class).

(Note that I'm struggling with the ISerializable interface, and would
be happy to leave that out of the conversation).

TIA,
Jim

Nov 17 '05 #2

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

Similar topics

2
by: ALI-R | last post by:
I have written a class in C# and I have serilized into a file .I read somewhere that if you want a class to be serializble you must add an attribute called before the class and within the...
5
by: Ben Terry | last post by:
I get the following compilation error: "The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)" Can anyone tell me why the...
0
by: Poewood | last post by:
I am experimenting with saving files in binary format on the Pocket PC. When I use the attribute I get error in Compact Framework. Do i have to use the attribute to make a class serializable? ...
1
by: Frank Rizzo | last post by:
What is the performance impact of setting a attribute on a class? Is there a performance win if I remove the attribute? I am doing some perf profiling and realized that all my strongly type...
0
by: Joshua Belden | last post by:
I have a class that is marked as Serializable that implements INotifyPropertyChanged. private event PropertyChangedEventHandler _PropertyChanged; public event PropertyChangedEventHandler...
1
by: Harshdeep Mehta | last post by:
Hi all, I have written a page in which I want to preserve value of object - suppose A - value, so I used viewstate. but that give me error. Code : ViewState = objClassA; // Before PostBack...
9
by: Developer | last post by:
Hi, How can one tell wsdl.exe/VS.NET web service proxy generatioon to to put on imported classes? For example, i fin your web service you use a class: class Data { }
2
by: Prakash | last post by:
Hi Friends, In my C# application, i have tried to serialize some structured data using Soapformatter. While calling the serialize funciton i got the exception message like "mscorlib....The...
1
by: Cirene | last post by:
I'm binding a datagrid to my business object. I get an error that the type 'abcshoppingcart'...is not marked as serializable. So, I added a attribute in the class. But then a blue squiggly...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.