473,569 Members | 2,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determining Specified Elements After Deserialization

Jay
Hello all. When using the XmlSerializer, you can create a
property/field that tells the serializer whether or not to bother
putting an element in the document. For example:

// C# example.
public class MyClass {
[XmlIgnore]
public bool MyPropSpecified ;

public int MyProp;
}

If MyPropSpecified is true, the XmlSerializer will serialize the MyProp
property into the document. If it's false, the serializer skips it
entirely.

Is there a way this can be used in the inverse? When deserializing a
document containing a MyClass object, is there a way that I can tell
which one of the two situations occurred:
1) MyProp was specified in the document, and had a value of 0.
2) MyProp was not specified in the document, and the only reason
MyProp has a value of 0 is because that's how C# defaulted it.
Thanks,
Jay

Nov 12 '05 #1
1 1678
// C# example.
public class MyClass {
[XmlIgnore]

"XmlIgnore"
Yahnnnn

"Jay" <ja*@classless. net> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hello all. When using the XmlSerializer, you can create a
property/field that tells the serializer whether or not to bother
putting an element in the document. For example:

// C# example.
public class MyClass {
[XmlIgnore]
public bool MyPropSpecified ;

public int MyProp;
}

If MyPropSpecified is true, the XmlSerializer will serialize the MyProp
property into the document. If it's false, the serializer skips it
entirely.

Is there a way this can be used in the inverse? When deserializing a
document containing a MyClass object, is there a way that I can tell
which one of the two situations occurred:
1) MyProp was specified in the document, and had a value of 0.
2) MyProp was not specified in the document, and the only reason
MyProp has a value of 0 is because that's how C# defaulted it.
Thanks,
Jay


Nov 12 '05 #2

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

Similar topics

35
5142
by: Dr.Tube | last post by:
Hi there, I have this web site (www.DrTube.com) which has the following DTD: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> which switches Mozilla to standards compliance mode as I can confirm myself. How can I check whether IE6 and Opera do so too? TIA Regards Xavier van Unen.
0
1083
by: Satish Gidugu | last post by:
I am using .NET 1.1. I need to serialize an object with a string property marked with attribute. It is possible for the string property to be a series of whitespaces. However, after deserialization, all I get is an empty string. Is there any to preserve the whitespaces? This works fine as long as the string property is serialized as an...
0
1090
by: Ryan B | last post by:
Hi there, I've been searching the posts in this group and haven't been able to find anything that suitably solves my problem.. anyway... I am attempting to deserialize a class which I do not own, but the XML generated can potentially be HUGE (as in, gigabytes), so I do not want to deserialize all of it at once. Anyway, here's an...
3
1618
by: Fred Nelson | last post by:
I'm devloping a Web Application in VB.NET. In my web.config file I have specified that untrapped errors are to be sent to the page "errorpage.aspx". This is working fine - if an untrapped error occurs the application is indeed routed to this page. On this page I would like to determine the cause of the error and either log it in a file or...
4
2150
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is broken in Firefox 1.5.0.1 on OS X. What happens with the Scriptaculous library is this In the html document the author only has to include one...
3
3130
by: GT | last post by:
I have a .NET client that consumes an Axis web service. A change was made recently to the AXIS web service, and ever since then my .NET proxy class has been throwing an InvalidCastException. The proxy class was auto-generated by Visual Studio from WSDL provided by people who provide the Axis service, and I have not modified it (except to add...
7
2166
by: Jason | last post by:
I have some XML that contains some null elements, for example: <Document> <StartDate/> <EndDate/> </Document> I would like to process the XML using the .NET serialization tools (XSD.exe). The schema for the XML is under external control (i.e. I can't change it).
3
5256
by: =?Utf-8?B?S2VubmV0aCBILiBCcmFubmlnYW4=?= | last post by:
Hello, I was wondering if there is a way to have the contents of an XML element that contains HTML to be deserialized into the cooresponding string property without the HTML tags being surronded by CDATA? <?xml version="1.0" encoding="UTF-8" ?> <introduction> <header> <h1>Helping you achieve the natural look you want</h1> </header>
1
6081
by: novicedlh | last post by:
Hello, I am creating a webservice that collects user information and stores it in a database. Since the user information contains sensitive data like SSN I am planning to use WS-Security (WSE 2.0) in my WebService to digitally sign and encrypt the data. Here are the steps I followed to digitally sign the message: 1) I created a X.509...
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7917
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.