Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » XML » Serializing » Downloads
 
Add your own
alternative version

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-src-1.1.zip
YAXLib
DemoApplication
Properties
Settings.settings
SampleClasses
YAXLib
Properties
YAXLib-src-1.zip
Settings.settings
YAXLib-src-1_1.zip
Settings.settings
YAXLib-src-2.0.zip
Settings.settings
LocalTestRun.testrunconfig
YAXLib.vsmdi
YAXLibTests
Properties
Test References
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YAXLib
{
    /// <summary>
    /// Holds the list of errors occurred
    /// </summary>
    public class YAXParsingErrors
    {
        private List<KeyValuePair<YAXException, YAXExceptionTypes>> m_listExceptions = new List<KeyValuePair<YAXException, YAXExceptionTypes>>();

        /// <summary>
        /// Adds an exception with the corresponding type.
        /// </summary>
        /// <param name="ex">The exception to add.</param>
        /// <param name="exType">Type of the exception added.</param>
        public void AddException(YAXException ex, YAXExceptionTypes exType)
        {
            m_listExceptions.Add(new KeyValuePair<YAXException, YAXExceptionTypes>(ex, exType));
        }

        /// <summary>
        /// Clears the list of errors.
        /// </summary>
        public void ClearErrors()
        {
            m_listExceptions.Clear();
        }

        /// <summary>
        /// Adds the list of errors within another instance of <c>YAXParsingErrors</c>.
        /// </summary>
        /// <param name="parsingErrors">The parsing errors to add its content.</param>
        public void AddRange(YAXParsingErrors parsingErrors)
        {
            foreach(var v in parsingErrors.m_listExceptions)
            {
                m_listExceptions.Add(v);
            }
        }

        /// <summary>
        /// Gets a value indicating whether the list of errors is empty or not.
        /// </summary>
        /// <value><c>true</c> if the list is not empty; otherwise, <c>false</c>.</value>
        public bool ContainsAnyError
        {
            get
            {
                return m_listExceptions.Count > 0;
            }
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var pair in m_listExceptions)
            {
                sb.AppendLine(String.Format("{0,-8} : {1}", pair.Value, pair.Key.Message));
                sb.AppendLine();
            }

            return sb.ToString();
        }

        /// <summary>
        /// Gets the number of errors within the list of errors.
        /// </summary>
        /// <value>the number of errors within the list of errors.</value>
        public int Count
        {
            get
            {
                return m_listExceptions.Count;
            }
        }

        /// <summary>
        /// Gets the the pair of Exception and its corresponding exception-type with the specified n.
        /// </summary>
        /// <value></value>
        public KeyValuePair<YAXException, YAXExceptionTypes> this[int n]
        {
            get
            {
                return m_listExceptions[n];
            }
        }
    }
}

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
Follow on   Twitter   Google+

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