Example #1
0
        public FieldToken(TypeToken parent, FieldInfo fieldInfo, int index) : base(parent, fieldInfo, index)
        {
            _memberInfo = fieldInfo;

            TypeToken = parent.GetChildToken(fieldInfo.FieldType);

            if (IsArray)
            {
                var fbAttr = _memberInfo.GetCustomAttribute <FixedBufferAttribute>();
                if (fbAttr != null)
                {
                    Cardinality = fbAttr.Length;
                }
                else
                {
                    var cardinalityAttribute = _memberInfo.GetCustomAttribute <CardinalityAttribute>();
                    if (cardinalityAttribute != null)
                    {
                        Cardinality = cardinalityAttribute.SizeConst;
                    }
                    else
                    {
                        var marshalAttr = _memberInfo.GetCustomAttribute <MarshalAsAttribute>();
                        if (marshalAttr != null)
                        {
                            Cardinality = marshalAttr.SizeConst;
                        }
                    }
                }
            }
        }
Example #2
0
        public PropertyToken(TypeToken parent, PropertyInfo propInfo, int index) : base(parent, propInfo, index)
        {
            _propInfo = propInfo;

            TypeToken = parent.GetChildToken(propInfo.PropertyType);

            if (IsArray)
            {
                var fbAttr = _propInfo.GetCustomAttribute <FixedBufferAttribute>();
                if (fbAttr != null)
                {
                    Cardinality = fbAttr.Length;
                }
                else
                {
                    var cardinalityAttribute = _propInfo.GetCustomAttribute <CardinalityAttribute>();
                    if (cardinalityAttribute != null)
                    {
                        Cardinality = cardinalityAttribute.SizeConst;
                    }
                }
            }
        }