public ReadElementContentAsDateTime ( ) : System.DateTime | ||
Résultat | System.DateTime |
public object ReadValue(XmlDictionaryReader reader) { object obj2; if (!this.isArray) { switch (this.typeCode) { case TypeCode.Int32: return reader.ReadElementContentAsInt(); case TypeCode.Int64: return reader.ReadElementContentAsLong(); case TypeCode.Single: return reader.ReadElementContentAsFloat(); case TypeCode.Double: return reader.ReadElementContentAsDouble(); case TypeCode.Decimal: return reader.ReadElementContentAsDecimal(); case TypeCode.DateTime: return reader.ReadElementContentAsDateTime(); case TypeCode.String: return reader.ReadElementContentAsString(); case TypeCode.Boolean: return reader.ReadElementContentAsBoolean(); } throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidUseOfPrimitiveOperationFormatter"))); } switch (this.typeCode) { case TypeCode.Boolean: if (reader.IsEmptyElement) { reader.Read(); return new bool[0]; } reader.ReadStartElement(); obj2 = reader.ReadBooleanArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Byte: return reader.ReadElementContentAsBase64(); case TypeCode.Int32: if (reader.IsEmptyElement) { reader.Read(); return new int[0]; } reader.ReadStartElement(); obj2 = reader.ReadInt32Array(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Int64: if (reader.IsEmptyElement) { reader.Read(); return new long[0]; } reader.ReadStartElement(); obj2 = reader.ReadInt64Array(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Single: if (reader.IsEmptyElement) { reader.Read(); return new float[0]; } reader.ReadStartElement(); obj2 = reader.ReadSingleArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Double: if (reader.IsEmptyElement) { reader.Read(); return new double[0]; } reader.ReadStartElement(); obj2 = reader.ReadDoubleArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.Decimal: if (reader.IsEmptyElement) { reader.Read(); return new decimal[0]; } reader.ReadStartElement(); obj2 = reader.ReadDecimalArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; case TypeCode.DateTime: if (reader.IsEmptyElement) { reader.Read(); return new DateTime[0]; } reader.ReadStartElement(); obj2 = reader.ReadDateTimeArray(this.itemName, this.itemNamespace); reader.ReadEndElement(); return obj2; } throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidUseOfPrimitiveOperationFormatter"))); }
public object ReadValue(XmlDictionaryReader reader) { object value; if (_isArray) { switch (_typeCode) { case TypeCode.Byte: value = reader.ReadElementContentAsBase64(); break; case TypeCode.Boolean: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadBooleanArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<bool>(); } break; case TypeCode.DateTime: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadDateTimeArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<DateTime>(); } break; case TypeCode.Decimal: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadDecimalArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Decimal>(); } break; case TypeCode.Int32: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadInt32Array(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Int32>(); } break; case TypeCode.Int64: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadInt64Array(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Int64>(); } break; case TypeCode.Single: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadSingleArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Single>(); } break; case TypeCode.Double: if (!reader.IsEmptyElement) { reader.ReadStartElement(); value = reader.ReadDoubleArray(_itemName, _itemNamespace); reader.ReadEndElement(); } else { reader.Read(); value = Array.Empty<Double>(); } break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxInvalidUseOfPrimitiveOperationFormatter)); } } else { switch (_typeCode) { case TypeCode.Boolean: value = reader.ReadElementContentAsBoolean(); break; case TypeCode.DateTime: value = reader.ReadElementContentAsDateTime(); break; case TypeCode.Decimal: value = reader.ReadElementContentAsDecimal(); break; case TypeCode.Double: value = reader.ReadElementContentAsDouble(); break; case TypeCode.Int32: value = reader.ReadElementContentAsInt(); break; case TypeCode.Int64: value = reader.ReadElementContentAsLong(); break; case TypeCode.Single: value = reader.ReadElementContentAsFloat(); break; case TypeCode.String: return reader.ReadElementContentAsString(); default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxInvalidUseOfPrimitiveOperationFormatter)); } } return value; }
public static object Deserialize(XmlDictionaryReader reader, Type targetType) { object returnValue = null; if (reader.IsStartElement()) { switch (reader.LocalName) { case XmlRpcProtocol.Nil: returnValue = null; break; case XmlRpcProtocol.Bool: returnValue = Convert.ChangeType((reader.ReadElementContentAsInt()==1),targetType); break; case XmlRpcProtocol.ByteArray: if (targetType == typeof(Stream)) { returnValue = new MemoryStream(reader.ReadElementContentAsBase64()); } else { returnValue = Convert.ChangeType(reader.ReadElementContentAsBase64(), targetType); } break; case XmlRpcProtocol.DateTime: returnValue = Convert.ChangeType(reader.ReadElementContentAsDateTime(),targetType); break; case XmlRpcProtocol.Double: returnValue = Convert.ChangeType(reader.ReadElementContentAsDouble(),targetType); break; case XmlRpcProtocol.Int32: case XmlRpcProtocol.Integer: returnValue = Convert.ChangeType(reader.ReadElementContentAsString(),targetType); break; case XmlRpcProtocol.String: if (targetType == typeof(Uri)) { returnValue = new Uri(reader.ReadElementContentAsString()); } else { returnValue = Convert.ChangeType(reader.ReadElementContentAsString(), targetType); } break; case XmlRpcProtocol.Struct: returnValue = DeserializeStruct(reader, targetType); break; case XmlRpcProtocol.Array: if (targetType.IsArray || targetType is IEnumerable || targetType is IList || targetType is ICollection) { reader.ReadStartElement(XmlRpcProtocol.Array); ArrayList arrayData = new ArrayList(); reader.ReadStartElement(XmlRpcProtocol.Data); reader.MoveToContent(); while (reader.IsStartElement(XmlRpcProtocol.Value)) { reader.ReadStartElement(); arrayData.Add(Deserialize(reader, targetType.GetElementType())); reader.ReadEndElement(); reader.MoveToContent(); } if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == XmlRpcProtocol.Data) { reader.ReadEndElement(); } reader.ReadEndElement(); if (targetType is IEnumerable || targetType is IList || targetType is ICollection) { returnValue = arrayData; } else { returnValue = arrayData.ToArray(targetType.GetElementType()); } } else { throw new InvalidOperationException(); } break; } } return returnValue; }