public List <BlendValueCapsule> DereferenceAll(IBlendType type) { if (!CanDereference(type)) { return(null); } var result = new List <BlendValueCapsule>(); try { int offset = (int)m_address; IBlendType realType; using (var reader = new BinaryReader(m_mapper.GetStreamFromAddress(m_address, out realType))) { type = realType != null ? realType : type; // if the given type is not equals to the real stored type, we belieave the real stored type. result.Capacity = (int)reader.BaseStream.Length / type.SizeOf(); var context = new ReadValueContext() { reader = reader, mapper = m_mapper }; while (reader.BaseStream.Position < reader.BaseStream.Length) { var val = type.ReadValue(context); result.Add(val); } } } catch (Exception e) { throw new BlenderException("Failed to dereference {0} as {1}", AddressString, type.Name); } return(result); }
/// <summary> /// get size of this type /// </summary> /// <returns>size [byte]</returns> public virtual int SizeOf() { int size = m_baseType.SizeOf(); int elemCount = 1; if (m_dimCountArray != null) { for (int indexDim = 0; indexDim < ArrayDimension; ++indexDim) { elemCount *= m_dimCountArray[indexDim]; } } return(size * elemCount); }