91 lines
2.8 KiB
C#
91 lines
2.8 KiB
C#
|
|
/*
|
|||
|
|
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
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Attribute for specifying the XML serialization tag for the attached
|
|||
|
|
/// object member entity.
|
|||
|
|
/// </summary>
|
|||
|
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
|||
|
|
public class XmlSerializationTagAttribute : Attribute, IComparable<XmlSerializationTagAttribute>
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Get the <see cref="string"/> value of this tag attribute.
|
|||
|
|
/// </summary>
|
|||
|
|
public string Value { get; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Get the <see cref="int"/> order of the tag attribute. This will be used in sorting
|
|||
|
|
/// the like-tag attributes attached to the same object.
|
|||
|
|
/// </summary>
|
|||
|
|
public int Order { get; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Initialize an instance of the XmlSerializationTagAttribute class.
|
|||
|
|
/// </summary>
|
|||
|
|
///
|
|||
|
|
/// <param name="value">
|
|||
|
|
/// The <see cref="string"/> value of this attribute.
|
|||
|
|
/// </param>
|
|||
|
|
///
|
|||
|
|
public XmlSerializationTagAttribute(string value) : this(value, 0)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Initialize an instance of the XmlSerializationTagAttribute class.
|
|||
|
|
/// </summary>
|
|||
|
|
///
|
|||
|
|
/// <param name="value">
|
|||
|
|
/// The <see cref="string"/> value of this attribute.
|
|||
|
|
/// </param>
|
|||
|
|
///
|
|||
|
|
/// <param name="order">
|
|||
|
|
/// The <see cref="int"/> order of this attribute. This will be used in sorting
|
|||
|
|
/// the like-tag attributes attached to the same object.
|
|||
|
|
/// </param>
|
|||
|
|
///
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Compare this object to the one specified.
|
|||
|
|
/// </summary>
|
|||
|
|
///
|
|||
|
|
/// <param name="that">The <see cref="Xml.XmlSerializationTagAttribute"/>
|
|||
|
|
/// tag to compare to</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
///
|
|||
|
|
public int CompareTo(XmlSerializationTagAttribute that)
|
|||
|
|
{
|
|||
|
|
return Order.CompareTo(that.Order);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|