Esempio n. 1
0
    private void BuildData()
    {
        MemoryStream buffer = new MemoryStream();

        byte[] bytes;
        data       = "";
        dataString = "";
        StringBuilder debugBuffer = new StringBuilder();

        using (DeflateStream stream = new DeflateStream(buffer, CompressionLevel.Optimal)) {
            stream.WriteInt(array.Length);
            if (DebugEnabled)
            {
                debugBuffer.Append("[");
            }

            foreach (int i in array)
            {
                stream.WriteInt(i);

                if (DebugEnabled)
                {
                    debugBuffer.Append(i);
                    debugBuffer.Append(",");
                }
            }

            if (DebugEnabled)
            {
                debugBuffer.Remove(debugBuffer.Length - 1, 1);
                debugBuffer.Append("]");
            }
        }

        bytes      = buffer.ToArray();
        data       = Convert.ToBase64String(bytes);
        dataString = debugBuffer.ToString();
    }