/*
XmlSerializationTagAttribute.cs
Copyright © 2008
Diversified Technical Systems
All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace DTS.Common.Utilities.Xml
{
///
/// Attribute for specifying the XML serialization tag for the attached
/// object member entity.
///
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
public class XmlSerializationTagAttribute : Attribute, IComparable
{
///
/// Get the value of this tag attribute.
///
public string Value { get; }
///
/// Get the order of the tag attribute. This will be used in sorting
/// the like-tag attributes attached to the same object.
///
public int Order { get; }
///
/// Initialize an instance of the XmlSerializationTagAttribute class.
///
///
///
/// The value of this attribute.
///
///
public XmlSerializationTagAttribute(string value) : this(value, 0)
{
}
///
/// Initialize an instance of the XmlSerializationTagAttribute class.
///
///
///
/// The value of this attribute.
///
///
///
/// The order of this attribute. This will be used in sorting
/// the like-tag attributes attached to the same object.
///
///
public XmlSerializationTagAttribute(string value, int order)
{
try
{
Value = value;
Order = order;
}
catch (Exception ex)
{
throw new Exception(
string.Format(
Properties.Resources.Generic_EncounteredProblemConstructingClassString, GetType().FullName),
ex);
}
}
///
/// Compare this object to the one specified.
///
///
/// The
/// tag to compare to
///
///
public int CompareTo(XmlSerializationTagAttribute that)
{
return Order.CompareTo(that.Order);
}
}
}