Solved

How do I serialize a Dictionary<String,T> collection using the XMLSerializer in .Net/C#?

Posted on 2013-01-22
3
533 Views
Last Modified: 2013-01-25
Hi:

I'm trying to figure out the best way use the XMLSerializer to serialize a Dictionary<String,T> and a Dictionary<String, <List>> object.

I have a class that has something that resembles the following definition:

 public class TemplateFile
    {
        /// <summary>
        ///
        /// </summary>
        private Dictionary<String, EntityClass> dEntities = new Dictionary<string,EntityClass>();
        public Dictionary<String, EntityClass> Entities
        {
            get { return dEntities; }
            set { dEntities = value; }
        }

        /// <summary>
        ///
        /// </summary>
        public Dictionary<String, List<EntityClass>> ListEntities = new Dictionary<string,List<EntityClass>>();
   }

What is the best way to acheive this?

Thanks,
JohnB
0
Comment
Question by:jxbma
3 Comments
 
LVL 9

Expert Comment

by:sognoct
ID: 38807602
check if this library can help you :
http://www.sharpserializer.com/en/index.html
0
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 500 total points
ID: 38808260
To my knowledge XMLSerializer does not support Dictionary serialization.

One possible way to solve the problem is in the solution:
http://stackoverflow.com/questions/2911514/why-doesnt-xmlserializer-support-dictionary
0
 
LVL 1

Author Closing Comment

by:jxbma
ID: 38819295
That certainly was 1 option.
I basically collapsed the dictionary into a list where each entry contained my dictionary key.
i was then able to serialize what I need to.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now