//
// PacketIndexAttribute.cs
//
// Copyright (c) František Boháček. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace NosSmooth.PacketSerializer.Abstractions.Attributes;
///
/// Attribute for marking properties in packets with their position in the packet.
///
[AttributeUsage(AttributeTargets.Parameter)]
public class PacketIndexAttribute : Attribute
{
///
/// Initializes a new instance of the class.
///
/// The position of the property.
public PacketIndexAttribute(ushort index)
{
Index = index;
}
///
/// Gets the index of the current property.
///
public ushort Index { get; }
///
/// Gets the inner separator used for complex types such as sub packets.
///
public char InnerSeparator { get; set; } = (char)0xFF;
///
/// Gets the separator after this field.
///
public char AfterSeparator { get; set; } = (char)0xFF;
///
/// Gets or sets whether this parameter is optional.
///
///
/// Optional attributes have to be nullable,
/// if the attribute is not in the string,
/// it will be set to null. For serializer,
/// if the parameter is null, it will be omitted.
///
/// See for
/// more complex decision making about using parameters.
///
public bool IsOptional { get; set; } = false;
}