using System; namespace Esiur.Data; /// /// Assigns a stable wire index to a field or property of a . /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)] public sealed class IndexAttribute : Attribute { /// /// Gets or sets the byte-sized index used on the wire. /// public byte Index { get; set; } public IndexAttribute() { } public IndexAttribute(int index) { if (index < byte.MinValue || index > byte.MaxValue) throw new ArgumentOutOfRangeException(nameof(index), "A structure index must be between 0 and 255."); Index = (byte)index; } }