Click here to Skip to main content
12,243,173 members (19,521 online)
Click here to Skip to main content
Articles » Languages » XML » Serializing » Downloads

Stats

190.6K views
269 downloads
205 bookmarked
Posted

Yet Another XML Serialization Library for the .NET Framework

, 2 Oct 2012 MIT
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
// Copyright 2009 - 2010 Sina Iravanian - <sina@sinairv.com>
//
// This source file(s) may be redistributed, altered and customized
// by any means PROVIDING the authors name and all copyright
// notices remain intact.
// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED. USE IT AT YOUR OWN RISK. THE AUTHOR ACCEPTS NO
// LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE.
//-----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace YAXLib
{
    /// <summary>
    /// Provides deserializer methods for some known .NET built-in types.
    /// </summary>
    internal class KnownDotNetTypesDeserializers
    {
        /// <summary>
        /// Deserializes an object of type <c>TimeSpan</c>.
        /// </summary>
        /// <param name="baseElement">The XML element containing serialized <c>TimeSpan</c>.</param>
        /// <returns>deserialized <c>TimeSpan</c> object.</returns>
        public static object DeserializeTimeSpan(XElement baseElement)
        {
            string strTicks = baseElement.Element("Ticks").Value;
            long ticks = 0L;
            if (Int64.TryParse(strTicks, out ticks))
            {
                return new TimeSpan(ticks);
            }
            return null;
        }

        /// <summary>
        /// Deserializes an object of type <c>GUID</c>.
        /// </summary>
        /// <param name="baseElement">The XML element containing serialized <c>GUID</c>.</param>
        /// <returns>deserialized <c>GUID</c> object</returns>
        internal static object DeserializeGuid(XElement baseElement)
        {
            string strGuidValue = baseElement.Value;
            Guid g = new Guid(strGuidValue);
            return g;
        }
    }
}

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...

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