本文整理汇总了C#中System.Xml.XmlDictionaryReader.ReadElementContentAsDateTime方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.ReadElementContentAsDateTime方法的具体用法?C# XmlDictionaryReader.ReadElementContentAsDateTime怎么用?C# XmlDictionaryReader.ReadElementContentAsDateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.ReadElementContentAsDateTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadValue
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();
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:PrimitiveOperationFormatter.cs
示例2: ReadValue
//.........这里部分代码省略.........
{
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;
}
示例3: Deserialize
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;
}
开发者ID:ehabqadah,项目名称:Distributed-Nodes-Network-Management,代码行数:85,代码来源:XmlRpcDataContractSerializer.cs