Пример #1
0
        public override void OnDeserialization(FileSchema schema)
        {
            foreach (StructElement s in schema.Structs)
            {
                // The array element is a struct.
                if (s.Name == DataType)
                {
                    DataElement = s;
                    return;
                }
            }

            // Treat specified DataType as FieldElement.
            FieldElement field = new FieldElement();
            field.DataType = DataType;
            field.FormatType = FormatType;
            field.Name = "ArrayElement";
            DataElement = field;
        }
Пример #2
0
 public StructInstance(ElementInstance parent, Element[] elements)
     : base(parent)
 {
     _elements = elements;
 }
Пример #3
0
 public ArrayInstance(ElementInstance parent, Element type, Object[] elements)
     : base(parent)
 {
     this.Type = type;
     this.Elements = elements;
 }
Пример #4
0
        /// <summary>
        /// Calculate array size
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public static int CalcElementArraySize(Element[] elements)
        {
            int size = 0;

            if (elements != null)
            {
                foreach (Element elem in elements)
                {
                    if (elem.Size < 0)
                    {
                        return -1;	// there is a variable-length field.
                    }

                    size += elem.Size;
                }
            }

            return size;
        }