Example #1
0
        internal override DynamicTableEntity ToEntity(string rowkey)
        {
            // The row key is ignored
            var entity = new DynamicTableEntity(this.Controller.ToString(), GUID + ":" + rowkey);

            entity.Properties["GUID"] = new EntityProperty(GUID);
            entity.Properties["Name"] = new EntityProperty(Name);

            // Store mold data as RLE-compressed byte stream
            var compressed = RunLengthEncoder.Encode(Data);
            var bytes      = new List <byte>();

            foreach (var x in compressed)
            {
                var buf = BitConverter.GetBytes(x);
                if (!BitConverter.IsLittleEndian)
                {
                    Array.Reverse(buf);
                }
                bytes.AddRange(buf);
            }

            entity.Properties["Data"] = new EntityProperty(bytes.ToArray());
            return(entity);
        }
Example #2
0
        public MoldData(DynamicTableEntity entity) : base(entity)
        {
            GUID = GuidEncoder.Decode(entity.RowKey);
            Name = entity.Properties["Name"].StringValue;

            var bytes      = entity.Properties["Data"].BinaryValue;
            var compressed = new List <int>();

            for (var x = 0; x < bytes.Length; x += 4)
            {
                compressed.Add(BitConverter.ToInt32(bytes, x));
            }

            Data = RunLengthEncoder.Decode(compressed.ToArray());
        }