Click here to Skip to main content
13,140,613 members (44,906 online)
Click here to Skip to main content
Articles » Languages » XML » Serializing » Downloads

Stats

234.7K views
206 bookmarked
Posted 13 Mar 2009
MIT

Yet Another XML Serialization Library for the .NET Framework

, 2 Oct 2012
A flexible XML serialization library that lets developers design the XML file structure, and select the exception handling policy. YAXLib supports polymorphic serialization and serializing generic and non-generic collection classes and arrays.
YAXLib
DemoApplication
Properties
SampleClasses
YAXLib
Properties
LocalTestRun.testrunconfig
YAXLib.vsmdi
YAXLibTests
Properties
Test References
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YAXLib;

namespace DemoApplication.SampleClasses
{
    [YAXComment(@"This example demonstrates usage of recursive collection serialization
                and deserialization. In this case a Dictionary whose Key, or Value is 
                another dictionary or collection has been used.")]
    public class NestedDicSample
    {
        public Dictionary<Dictionary<double, Dictionary<int, int>>, Dictionary<Dictionary<string, string>, List<double>>> SomeDic { get; set; }

        public override string ToString()
        {
            return GeneralToStringProvider.GeneralToString(this);
        }

        public static NestedDicSample GetSampleInstance()
        {
            var dicKV1 = new Dictionary<int, int>();
            dicKV1.Add(1, 1);
            dicKV1.Add(2, 2);
            dicKV1.Add(3, 3);
            dicKV1.Add(4, 4);

            var dicKV2 = new Dictionary<int, int>();
            dicKV2.Add(9, 1);
            dicKV2.Add(8, 2);

            var dicVK1 = new Dictionary<string, string>();
            dicVK1.Add("Test", "123");
            dicVK1.Add("Test2", "456");

            var dicVK2 = new Dictionary<string, string>();
            dicVK2.Add("Num1", "123");
            dicVK2.Add("Num2", "456");

            var dicK = new Dictionary<double, Dictionary<int, int>>();
            dicK.Add(0.99999, dicKV1);
            dicK.Add(3.14, dicKV2);

            var dicV = new Dictionary<Dictionary<string, string>, List<double>>();
            dicV.Add(dicVK1, new double[] { 0.98767, 232, 13.124}.ToList());
            dicV.Add(dicVK2, new double[] { 9.8767, 23.2, 1.34 }.ToList());

            var mainDic = new Dictionary<Dictionary<double, Dictionary<int, int>>, Dictionary<Dictionary<string, string>, List<double>>>();
            mainDic.Add(dicK, dicV);

            return new NestedDicSample()
            {
                SomeDic = mainDic
            };
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

Sina Iravanian
Software Developer
Australia Australia
A software designer and developer

You may also be interested in...

Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 2 Oct 2012
Article Copyright 2009 by Sina Iravanian
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid