/// <summary>
        /// Deserializes the contents of the given XML <paramref name="reader"/>'s current element in the formatting rules
        /// given by this data type.
        /// </summary>
        /// <param name="reader">XML reader whose current element's value will be deserialized.
        /// The reader's position is the start of the parent element, the result should go. After this method returns, the reader
        /// must have read the end element.</param>
        /// <returns>Deserialized object of this data type (may be <c>null</c>).</returns>
        public object SoapDeserializeValue(XmlReader reader)
        {
            object result;

            if (SoapHelper.ReadNull(reader))
            {
                result = null;
            }
            else
            {
                switch (_upnpTypeName)
                {
                case "ui1":
                case "ui2":
                case "ui4":
                case "ui8":
                case "i1":
                case "i2":
                case "i4":
                case "i8":
                case "int":
                case "r4":
                case "r8":
                case "number":
                case "fixed.14.4":
                case "float":
                case "char":
                    result = reader.ReadElementContentAs(_dotNetType, null);
                    break;

                case "string":
                case "uuid":
                    result = reader.ReadElementContentAsString();
                    break;

                case "date":
                    result = System.DateTime.ParseExact(reader.ReadElementContentAsString(), "yyyy-MM-dd", null);
                    break;

                case "dateTime":
                    result = System.DateTime.ParseExact(reader.ReadElementContentAsString(), "s", null);
                    break;

                case "dateTime.tz":
                    result = System.DateTime.ParseExact(reader.ReadElementContentAsString(), "u", null).ToLocalTime();
                    break;

                case "time":
                    result = System.DateTime.ParseExact(reader.ReadElementContentAsString(), "T", null);
                    break;

                case "time.tz":
                    result = System.DateTime.ParseExact(reader.ReadElementContentAsString(), "hh:mm:ss", null).ToLocalTime();
                    break;

                case "boolean":
                    result = reader.ReadElementContentAs(_dotNetType, null);
                    break;

                case "bin.base64":
                    result = reader.ReadElementContentAs(_dotNetType, null);
                    break;

                case "bin.hex":
                    result = EncodingUtils.FromHexString(reader.ReadElementContentAsString());
                    break;

                case "uri":
                    result = new Uri(reader.ReadElementContentAsString());
                    break;

                default:
                    throw new NotImplementedException(string.Format("UPnP standard data type '{0}' is not implemented", _upnpTypeName));
                }
                // Reader will already have read the end element in the methods ReadElementContentXXX
            }
            return(result);
        }