public FieldRenderInfo(object field, UpdateFieldType type) { Field = field; Type = type; Name = FieldRenderUtil.GetFriendlyName(field); FieldRenderUtil.CustomRenderers.TryGetValue(field, out Renderer); if (Renderer == null) { Renderer = FieldRenderUtil.TypeRenderers[(int)Type]; } Index = Convert.ToUInt32(field); }
internal byte[] ReadMask(uint blockCount, uint valueSize, string name, Action <uint, byte[]> parser) { var bitFields = new uint[blockCount][]; var totalCount = 0; for (var j = 0; j < blockCount; j++) { var mask = ReadUIntAmount(valueSize); bitFields[j] = Utility.GetSetIndices(mask); totalCount += bitFields[j].Length; } var fieldCount = 8 * valueSize; var blockSize = fieldCount * valueSize; // a block has 8 * valueSize fields and each field has again valueSize bytes var values = new byte[blockSize * bitFields.Length]; for (uint j = 0; j < blockCount; j++) { var bitField = bitFields[j]; for (uint k = 0; k < bitField.Length; k++) { var bit = bitField[k]; var index = j * blockSize + (bit * valueSize); try { parser(index, values); } catch (Exception e) { var field = index / valueSize; var msg = string.Format("Unable to parse {0} of UpdateBlock at index {1} ({7})\n\tBlocks: {2}/{3}\n\tField: {4} ({5}/{6})", name, index, j + 1, blockCount, bit, k + 1, bitField.Length, FieldRenderUtil.GetFriendlyName(ObjectType, field)); LogUtil.ErrorException(e, msg); return(values.ToArray()); } } } return(values.ToArray()); }