// reuse an entry // we will try to reuse arrays if possible public void LoadFromType(DynamicDataType type) { if (type.Bools > 0) { if (Bools == null || Bools.Length < type.Bools) { Bools = new bool[type.Bools]; } if (Bools.Length > 0) { PackedBoolSize = (8 + (Bools.Length - (Bools.Length % 8))) / 8; } } else { PackedBoolSize = 0; } if (type.Bytes > 0 && (Bytes == null || Bytes.Length < type.Bytes)) { Bytes = new byte[type.Bytes]; } if (type.UShorts > 0 && (UShorts == null || UShorts.Length < type.UShorts)) { UShorts = new ushort[type.UShorts]; } if (type.Ints > 0 && (Ints == null || Ints.Length < type.Ints)) { Ints = new int[type.Ints]; } if (type.Floats > 0 && (Floats == null || Floats.Length < type.Floats)) { Floats = new float[type.Floats]; } if (type.Doubles > 0 && (Doubles == null || Doubles.Length < type.Doubles)) { Doubles = new double[type.Doubles]; } if (type.Strings > 0) { if (Strings == null || Strings.Length < type.Strings) { Strings = new string[type.Strings]; } if (StringLengths == null || StringLengths.Length < type.Strings) { StringLengths = new int[type.Strings]; } } }
public DynamicDataEntry(DynamicDataType type) { DataType = type; if (type != null) { if (type.Bools > 0) { Bools = new bool[type.Bools]; if (Bools.Length > 0) { PackedBoolSize = (8 + (Bools.Length - (Bools.Length % 8))) / 8; } } if (type.Bytes > 0) { Bytes = new byte[type.Bytes]; } if (type.UShorts > 0) { UShorts = new ushort[type.UShorts]; } if (type.Ints > 0) { Ints = new int[type.Ints]; } if (type.Floats > 0) { Floats = new float[type.Floats]; } if (type.Doubles > 0) { Doubles = new double[type.Doubles]; } if (type.Strings > 0) { Strings = new string[type.Strings]; StringLengths = new int[type.Strings]; } } }
public void Clear() { DataType = null; PackedBoolSize = 0; TotalStringLengths = 0; }