protected override EsfNode CreateArrayNode(EsfType typeCode) { EsfNode result; // support array types for new primitives // this sets the type code of the base type to later have an easier time switch (typeCode) { case EsfType.BOOL_TRUE_ARRAY: case EsfType.BOOL_FALSE_ARRAY: case EsfType.UINT_ZERO_ARRAY: case EsfType.UINT_ONE_ARRAY: case EsfType.INT32_ZERO_ARRAY: case EsfType.SINGLE_ZERO_ARRAY: // trying to read this should result in an infinite loop throw new InvalidDataException(string.Format("Array {0:x} of zero-byte entries makes no sense", typeCode)); case EsfType.UINT32_BYTE_ARRAY: case EsfType.UINT32_SHORT_ARRAY: case EsfType.UINT32_24BIT_ARRAY: result = new OptimizedArrayNode <uint>(this, typeCode, delegate(uint val) { return(new OptimizedUIntNode { Value = val, SingleByteMin = true }); }); break; case EsfType.INT32_BYTE_ARRAY: case EsfType.INT32_SHORT_ARRAY: result = new OptimizedArrayNode <int>(this, typeCode, delegate(int val) { return(new OptimizedIntNode { Value = val, SingleByteMin = true }); }); break; default: result = base.CreateArrayNode(typeCode); return(result); } result.TypeCode = (EsfType)typeCode; return(result); }
protected override EsfNode CreateArrayNode(EsfType typeCode) { EsfNode esfNode; switch (typeCode) { case EsfType.BOOL_TRUE_ARRAY: case EsfType.BOOL_FALSE_ARRAY: case EsfType.UINT_ZERO_ARRAY: case EsfType.UINT_ONE_ARRAY: case EsfType.INT32_ZERO_ARRAY: case EsfType.SINGLE_ZERO_ARRAY: throw new InvalidDataException($"Array {typeCode:x} of zero-byte entries makes no sense"); case EsfType.UINT32_BYTE_ARRAY: case EsfType.UINT32_SHORT_ARRAY: case EsfType.UINT32_24BIT_ARRAY: esfNode = new OptimizedArrayNode <uint>(this, typeCode, (uint val) => new OptimizedUIntNode { Value = val, SingleByteMin = true }); break; case EsfType.INT32_BYTE_ARRAY: case EsfType.INT32_SHORT_ARRAY: esfNode = new OptimizedArrayNode <int>(this, typeCode, (int val) => new OptimizedIntNode { Value = val, SingleByteMin = true }); break; default: return(base.CreateArrayNode(typeCode)); } esfNode.TypeCode = typeCode; return(esfNode); }