Beispiel #1
0
        protected void DeserializeProperty(byte[] bytes, ref int index)
        {
            string propname = BinarySerializer.GetString(bytes, ref index);
            object value    = null;

            switch (propname)
            {
            case "width":
            case "height":
            case "top":
            case "bottom":
            case "left":
            case "right":
                value = BinarySerializer.GetFloat(bytes, ref index);
                break;

            case "background-color":
                value = BinarySerializer.GetColor(bytes, ref index);
                break;

            case "background":
                value = _serializedObjects[BinarySerializer.GetInt(bytes, ref index)];
                break;

            case "font":
                value = _serializedObjects[BinarySerializer.GetInt(bytes, ref index)];
                break;

            case "font-size":
                value = BinarySerializer.GetFloat(bytes, ref index);
                break;

            case "position":
            case "font-style":
            case "alignment":
            case "image-position":
            case "margin":
            case "padding":
                value = BinarySerializer.GetString(bytes, ref index);
                break;

            case "color":
                value = BinarySerializer.GetColor(bytes, ref index);
                break;

            case "expand-width":
                value = BinarySerializer.GetBool(bytes, ref index);
                break;

            case "expand-height":
                value = BinarySerializer.GetBool(bytes, ref index);
                break;

            case "min-width":
                value = BinarySerializer.GetFloat(bytes, ref index);
                break;

            case "min-height":
                value = BinarySerializer.GetFloat(bytes, ref index);
                break;

            case "max-width":
                value = BinarySerializer.GetFloat(bytes, ref index);
                break;

            case "max-height":
                value = BinarySerializer.GetFloat(bytes, ref index);
                break;

            default:
                throw new System.Exception(propname + " is not a supported property name, cannot deserialize");
            }
            _data.Add(propname, value);
        }