Пример #1
0
        public T Deserialize <T>(string key)
        {
            var type = typeof(T);

            if (type == typeof(string))
            {
                return((T)(object)xmlElement.GetAttribute(key));
            }
            else if (type == typeof(Vector2))
            {
                return((T)(object)xmlElement.GetVector2(key));
            }
            else if (type == typeof(Vector3))
            {
                return((T)(object)xmlElement.GetVector3(key));
            }
            else if (type == typeof(Vector4))
            {
                return((T)(object)xmlElement.GetVector4(key));
            }
            else if (type == typeof(Quaternion))
            {
                return((T)(object)xmlElement.GetQuaternion(key));
            }
            else if (type == typeof(Color))
            {
                return((T)(object)xmlElement.GetColor(key));
            }
            else if (type == typeof(float))
            {
                return((T)(object)xmlElement.GetFloat(key));
            }
            else if (type == typeof(double))
            {
                return((T)(object)xmlElement.GetDouble(key));
            }
            else if (type == typeof(int))
            {
                return((T)(object)xmlElement.GetInt(key));
            }
            else if (type == typeof(uint))
            {
                return((T)(object)xmlElement.GetUInt(key));
            }
            else if (type == typeof(bool))
            {
                return((T)(object)xmlElement.GetBool(key));
            }
            else
            {
                throw new NotSupportedException($"{type.Name} is not supported.");
            }
        }