using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Edge.Core.Parser.BinaryParser.Attributes
{
///
/// only for ListT structure, not for primitive array.
///
[AttributeUsage(AttributeTargets.Property)]
public class EnumerableFormatAttribute : AttributeBase
{
private EnumerableFormatAttribute()
{
// default set to 1 since the most possible used primitive type is byte.
this.ElementLength = 1;
}
///
///
///
/// The current Enumerable field has a constant count. like 2,3
///
public EnumerableFormatAttribute(int fixedCount, int index)
: this()
{
base.FixedLengthOrCount = fixedCount;
base.Index = index;
}
///
///
///
/// the current Enumerable field is variable count and determined by another field's numerical value, and the
/// numerical value directly reflect the original field count, like field 'IamTheCountLink' has the value 8, then the
/// linking field count is 8.
///
public EnumerableFormatAttribute(string countLink, int index)
: this()
{
base.LengthOrCountLink = countLink;
base.Index = index;
}
///
///
///
/// the current Enumerable field is variable count and determined by another field with numerical value, and the
/// numerical value is NOT directly reflect the original field length, have to use the argument 'countLinkExpression' together
/// to detect the length, like field 'IamTheCountLink' has the value 8, and the 'countLinkExpression' contains "8:12;", then the
/// original field count is actually 12.
///
///
public EnumerableFormatAttribute(string countLink, string countLinkExpression, int index)
: this()
{
base.LengthOrCountLink = countLink;
base.LengthOrCountLinkExpression = countLinkExpression;
base.Index = index;
}
///
/// If a fixed length field, then set the length value. otherwise, leave it.
///
public int ElementLength { get; private set; }
}
}