Ejemplo n.º 1
0
        private static ILayout GetFieldLayout(FieldInfo fieldInfo, LayoutManager layoutManager)
        {
            ILayout fieldLayout = null;
            Type    fieldType   = fieldInfo.FieldType;

            if (fieldType.IsArray)
            {
                ArraySizeAttribute ca = (ArraySizeAttribute)fieldInfo.GetCustomAttributes(typeof(ArraySizeAttribute)).FirstOrDefault();
                if (ca == null)
                {
                    throw new LayoutException("Array typed fields must use an ArraySize attribute to indicate their size");
                }
                fieldLayout = layoutManager.GetArrayLayout(fieldType, ca.NumElements);
            }
            else
            {
                fieldLayout = layoutManager.GetLayout(fieldType);
            }

            if (!fieldLayout.IsFixedSize)
            {
                throw new LayoutException(fieldInfo.Name + " is not a fixed size field. Only fixed size fields are supported in structures");
            }

            return(fieldLayout);
        }
Ejemplo n.º 2
0
        public T[] ReadArray <T>(ref ulong position, uint elementCount)
        {
            uint bytesRead;

            T[] ret = (T[])LayoutManager.GetArrayLayout <T[]>(elementCount).Read(DataSource, position, out bytesRead);
            position += bytesRead;
            return(ret);
        }
Ejemplo n.º 3
0
 public T[] ReadArray <T>(ulong position, uint elementCount)
 {
     return((T[])LayoutManager.GetArrayLayout <T[]>(elementCount).Read(DataSource, position));
 }