Ok the XmlSerializer is nice for my need.
BUT I what I need (maybe the XmlSerializer isnt what I need) is to be
able to take the following
objects
A Person who has a collection of Addresses
Person
(fname)
(lname)
Address
(Street)
(City)
(State)
(Zip)
And Serialize the Person object Seperatly from the Addresses.
What is the best way to do this ?
Inverse recursion ?
What I would like in the end are 2 strings, 1 representing the Person
and 1 representing the address.
If there were 2 addresses then 3 strings, 1 for the person, and 1 for
EACH address.
Thanks
Chris 4 1946
Hi Chris,
Could you just mark the address property of the Person object to be ignored
by the serializer (XmlIgnore i think). Serialise the Person to get your
first string, then iterate over the addresses and serialize them one by one?
ta,
Andrew
<cw******@gmail .comwrote in message
news:11******** **************@ 16g2000cwy.goog legroups.com...
Ok the XmlSerializer is nice for my need.
BUT I what I need (maybe the XmlSerializer isnt what I need) is to be
able to take the following
objects
A Person who has a collection of Addresses
Person
(fname)
(lname)
Address
(Street)
(City)
(State)
(Zip)
And Serialize the Person object Seperatly from the Addresses.
What is the best way to do this ?
Inverse recursion ?
What I would like in the end are 2 strings, 1 representing the Person
and 1 representing the address.
If there were 2 addresses then 3 strings, 1 for the person, and 1 for
EACH address.
Thanks
Chris
Hmm....thats a way...not bad.....
What I would really like to do is be able through reflection determine
if a property base type implments IEnumerable.
I have an app that I have several functions I need to determine if a
given propety is a a type of Collection
It could (and in most cases is) a Generic Collection
It could be , and array , an array list , etc though.
How can I determine if its A collection, or enumerable ?
I hate to impose contratints like that on Domain Design that all
collections must be ignored....etc.
BUT its better than what I had so far.
If I could just figure out how to determine if a property implments
IEnum, etc...
Thanks
Chris
Andrew Brook wrote:
Hi Chris,
Could you just mark the address property of the Person object to be ignored
by the serializer (XmlIgnore i think). Serialise the Person to get your
first string, then iterate over the addresses and serialize them one by one?
ta,
Andrew
<cw******@gmail .comwrote in message
news:11******** **************@ 16g2000cwy.goog legroups.com...
Ok the XmlSerializer is nice for my need.
BUT I what I need (maybe the XmlSerializer isnt what I need) is to be
able to take the following
objects
A Person who has a collection of Addresses
Person
(fname)
(lname)
Address
(Street)
(City)
(State)
(Zip)
And Serialize the Person object Seperatly from the Addresses.
What is the best way to do this ?
Inverse recursion ?
What I would like in the end are 2 strings, 1 representing the Person
and 1 representing the address.
If there were 2 addresses then 3 strings, 1 for the person, and 1 for
EACH address.
Thanks
Chris
System.Diagnost ics.Debug.Write Line("Addresses is " +
(typeof(IEnumer able).IsAssigna bleFrom(myObjec t.GetType().Get Property("Addre sses").Property Type)
? String.Empty : "not ") + "IEnumerabl e");
That should determine if your property is IEnumerable, although since
ICollection is derived from IEnumerable, it'd be better to check for
ICollection if you want to exclude them. But this is not behavior you can
dictate to the serializer (unless you can get it to fire the UnknownElement
event)
BINGO !
Thanks a TON !
It was driving me nuts, I was calling TypeOf differently and missing
the IsAssignableFro m
So NOW I can loop through my properties
You are 100% correct about the ICollection (I want thinking of the fact
ICollection is derived from IEnumerable)
What I plan to do as far as the serializer goes is loop from the Bottom
Up setting the collections to nothign after they have been individually
serialized. That Ive got ok, its not clean but it works.
Thanks again......
Keith Patrick wrote:
System.Diagnost ics.Debug.Write Line("Addresses is " +
(typeof(IEnumer able).IsAssigna bleFrom(myObjec t.GetType().Get Property("Addre sses").Property Type)
? String.Empty : "not ") + "IEnumerabl e");
That should determine if your property is IEnumerable, although since
ICollection is derived from IEnumerable, it'd be better to check for
ICollection if you want to exclude them. But this is not behavior you can
dictate to the serializer (unless you can get it to fire the UnknownElement
event)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stuart Robertson |
last post by:
I am trying to find a solution that will allow me to use XmlSerializer to serialize/deserialize a collection of objects where a given object is shared between two or more other objects, and not create duplicate XML representations of the shared object, but instead use IDREFs to refer to the shared object.
The XML I'm trying to produce is as follows (where "href" is an IDREF):
<?xml version="1.0" encoding="utf-8"?>
<MyRootClass...
|
by: Harris Boyce |
last post by:
Hello,
I'm trying to use the FOR XML EXPLICIT clause with SQL
Server to deserialize data from my database into a
strongly-typed collection object that I will use
throughout my application. I initially tested my design
by building a collection in code and then serializing it
to/from an XML file, which worked fine. However, I have
hit a brick wall trying to restore the data from SQL
Server. I originally had my collection and object
|
by: Bluetears76 |
last post by:
Hi I have a hirachy of classes which are Message(base), then
FileMessage and ChatMessage (extended)
I want to serialize the objects and when i am deserizaling i dont know
if i am getting FileMessage or ChatMessage. So how to get that object
and use it
I have written following code for serialization
public void Send(Message message)
{
NetworkStream netWorkStream=null;
|
by: MattB |
last post by:
Hello I got this working but it is not how I really want it, basically
I have an xml file which has a root of <test> and can be filled with 3
different types of <question> elements with different attributes, all
share a base set of 4, one of the question types can have children
with <option> elements, this is how the xml looks after
serialization....
If you notice there is an extra <SelectionList> around the <option>'s
in the
final...
|
by: SJD |
last post by:
I've just read Christoph Schittko's article on XmlSerializer:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp
. . . and very informative it is too.
I, too, am getting nasty FileNotFound exceptions. I've read, and
digested the article, and I think I've found a bug -- it's difficult to
track, though it does happen often.
| |
by: Steve Long |
last post by:
Hello,
I hope this is the right group to post this to. I'm trying to serialize a
class I've written and I'd like to be able to serialze to both binary and
xml formats. Binary serialization is working fine but when I try to
instantiate an XmlSerializer object with:
Dim xmls As New XmlSerializer(GetType(CLayerDefinition))
I get the following error:
|
by: Henrik Dahl |
last post by:
Hello!
I have an xml schema which has a date typed attribute. I have used xsd.exe
to create a class library for XmlSerializer. The result of
XmlSerializer.Serialize(...) should be passed as the value for the parameter
of an SqlCommand for inserting the xml document in a column of a table where
the column is typed to be of the same xml schema.
This all sounds simple, but SQL Server REQUIRES the timezone to be specified
for date values....
|
by: =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= |
last post by:
Hi,
I have a schema that has an optional element, fieldTag4000Field. If the
element is omitted from the XML request, when it is deserialized, it will be
null when I check it - which is fine.
What happens when the element is supplied as <fieldTag4000Field/(empty),
it does not equate to null. I want to be able handle this at the
deserialization level rahter than in my edits later.
|
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= |
last post by:
Hi,
I am using XML serialization for the first time and I have noticed
something unexpected. The object I am serializing contains a field
private NumericSettings _numericSettings;
public NumericSettings NumericSettings
{
get { return _numericSettings; }
}
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |