internal unsafe Dimension(byte *buffer, long bufferSize)
        {
            string value;
            var    offset = PersistedDataReader.ReadLegacyStringValue(buffer, bufferSize, out value);

            this.Name = value;

            PersistedDataReader.CheckRemainingBufferSize(bufferSize, offset, sizeof(int));
            var valueCount = *(int *)(buffer + offset);

            offset += sizeof(int);

            this.indexToValues = new List <string>(valueCount);
            while (valueCount > 0)
            {
                offset += PersistedDataReader.ReadLegacyStringValue((buffer + offset), bufferSize - offset,
                                                                    out value);

                if (this.valuesToIndex.ContainsKey(value))
                {
                    throw new PersistedDataException(string.Format("Duplicate dimension value {0} in {1}", value,
                                                                   this.Name));
                }
                this.valuesToIndex.Add(value, (uint)this.indexToValues.Count);
                this.indexToValues.Add(value);
                --valueCount;
            }

            this.SerializedSize = offset;
        }
        internal unsafe DimensionSet(byte *buffer, uint bufferSize)
        {
            long offset = 0;

            PersistedDataReader.CheckRemainingBufferSize(bufferSize, 0, sizeof(int));
            var dimensionCount = *(int *)buffer;

            offset += sizeof(int);

            this.dimensions = new Dimension[dimensionCount];
            for (var i = 0; i < dimensionCount; ++i)
            {
                this.dimensions[i] = new Dimension((buffer + offset), bufferSize - offset);
                offset            += this.dimensions[i].SerializedSize;
            }

            this.SerializedSize = offset;
        }