本文整理汇总了C#中System.Xml.XmlReader.ReadElementContentAsDateTime方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadElementContentAsDateTime方法的具体用法?C# XmlReader.ReadElementContentAsDateTime怎么用?C# XmlReader.ReadElementContentAsDateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadElementContentAsDateTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="preApproval"></param>
internal static void Read(XmlReader reader, PreApprovalSummary preApproval)
{
if (reader.IsEmptyElement)
{
XMLParserUtils.SkipNode(reader);
return;
}
reader.ReadStartElement(SerializerHelper.PreApproval);
reader.MoveToContent();
while (!reader.EOF)
{
if (XMLParserUtils.IsEndElement(reader, SerializerHelper.PreApproval))
{
XMLParserUtils.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case SerializerHelper.Code:
preApproval.Code = reader.ReadElementContentAsString();
break;
case SerializerHelper.Date:
preApproval.Date = reader.ReadElementContentAsDateTime();
break;
case SerializerHelper.Reference:
preApproval.Reference = reader.ReadElementContentAsString();
break;
case SerializerHelper.TransactionStatus:
preApproval.Status = reader.ReadElementContentAsString();
break;
case SerializerHelper.LastEventDate:
preApproval.LastEventDate = reader.ReadElementContentAsDateTime();
break;
case SerializerHelper.Name:
preApproval.Name = reader.ReadElementContentAsString();
break;
case SerializerHelper.Tracker:
preApproval.Tracker = reader.ReadElementContentAsString();
break;
case SerializerHelper.Charge:
preApproval.Charge = reader.ReadElementContentAsString();
break;
default:
XMLParserUtils.SkipElement(reader);
break;
}
}
else
{
XMLParserUtils.SkipNode(reader);
}
}
}
示例2: Communication
internal Communication(XmlReader rdr)
{
rdr.ReadStartElement("communication");
this.Id = rdr.ReadElementContentAsInt("id", "");
this.Subject = rdr.ReadElementString("subject");
this.Body = rdr.ReadElementString("body");
this.Date = rdr.ReadElementContentAsDateTime("date", "ctype");
this.Ctype = rdr.ReadElementString("");
this.Tags = Tag.BuildList(rdr);
this.Comments = MegaComment.BuildList(rdr);
this.CreateAt = rdr.ReadElementContentAsDateTime("created_at", "");
this.UpdatedAt = rdr.ReadElementContentAsDateTime("updated_at", "");
rdr.ReadEndElement();
}
示例3: ReadNextTdAsDate
private DateTime ReadNextTdAsDate(XmlReader reader)
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name.ToLower() == "td")
{
return reader.ReadElementContentAsDateTime();
}
}
return DateTime.MinValue;
}
示例4: Read
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="result">PagSeguro AuthorizationSummary</param>
internal static void Read(XmlReader reader, AuthorizationSummary result)
{
if (reader.IsEmptyElement)
{
XMLParserUtils.SkipNode(reader);
return;
}
reader.ReadStartElement(SerializerHelper.Authorization);
reader.MoveToContent();
while (!reader.EOF)
{
if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Authorization))
{
XMLParserUtils.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case SerializerHelper.Code:
result.Code = reader.ReadElementContentAsString();
break;
case SerializerHelper.CreationDate:
result.CreationDate = reader.ReadElementContentAsDateTime();
break;
case SerializerHelper.Reference:
result.Reference = reader.ReadElementContentAsString();
break;
case SerializerHelper.Account:
AuthorizationAccountSerializer.Read(reader, result);
break;
case SerializerHelper.Permissions:
AuthorizationPermissionListSerializer.Read(reader, result.Permissions);
break;
default:
XMLParserUtils.SkipElement(reader);
break;
}
}
else
{
XMLParserUtils.SkipNode(reader);
}
}
}
示例5: Read
internal static void Read(XmlReader reader, TransactionSearchResult result)
{
if (reader == null)
throw new ArgumentNullException("reader");
if (result == null)
throw new ArgumentNullException("result");
if (reader.IsEmptyElement)
{
SerializationHelper.SkipNode(reader);
return;
}
reader.ReadStartElement(TransactionSearchResultSerializer.TransactionSearchResult);
reader.MoveToContent();
while (!reader.EOF)
{
if (SerializationHelper.IsEndElement(reader, TransactionSearchResultSerializer.TransactionSearchResult))
{
SerializationHelper.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case TransactionSearchResultSerializer.Date:
result.Date = reader.ReadElementContentAsDateTime();
break;
case TransactionSearchResultSerializer.CurrentPage:
result.CurrentPage = reader.ReadElementContentAsInt();
break;
case TransactionSearchResultSerializer.TotalPages:
result.TotalPages = reader.ReadElementContentAsInt();
break;
case TransactionSummaryListSerializer.Transactions:
TransactionSummaryListSerializer.Read(reader, result.Items);
break;
default:
SerializationHelper.SkipElement(reader);
break;
}
}
else
{
SerializationHelper.SkipNode(reader);
}
}
}
示例6: Bucket
internal Bucket(XmlReader reader)
{
if (reader.IsEmptyElement)
throw new Exception("Expected a non-empty <Bucket> element.");
// Example:
// <Bucket>
// <Name>quotes;/Name>
// <CreationDate>2006-02-03T16:45:09.000Z</CreationDate>
// </Bucket>
reader.ReadStartElement("Bucket");
this.Name = reader.ReadElementContentAsString("Name", "");
this.CreationDate = reader.ReadElementContentAsDateTime("CreationDate", "");
reader.ReadEndElement();
}
示例7: Read
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="result"></param>
internal static void Read(XmlReader reader, PreApprovalSearchResult result)
{
if (reader.IsEmptyElement)
{
XMLParserUtils.SkipNode(reader);
return;
}
reader.ReadStartElement(PreApprovalSearchResultSerializer.PreApprovalSearchResult);
reader.MoveToContent();
while (!reader.EOF)
{
if (XMLParserUtils.IsEndElement(reader, PreApprovalSearchResultSerializer.PreApprovalSearchResult))
{
XMLParserUtils.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case PreApprovalSearchResultSerializer.Date:
result.Date = reader.ReadElementContentAsDateTime();
break;
case PreApprovalSearchResultSerializer.CurrentPage:
result.CurrentPage = reader.ReadElementContentAsInt();
break;
case PreApprovalSearchResultSerializer.TotalPages:
result.TotalPages = reader.ReadElementContentAsInt();
break;
case PreApprovalSummaryListSerializer.PreApprovals:
PreApprovalSummaryListSerializer.Read(reader, result.PreApprovals);
break;
default:
XMLParserUtils.SkipElement(reader);
break;
}
}
else
{
XMLParserUtils.SkipNode(reader);
}
}
}
示例8: Read
internal static void Read(XmlReader reader, PaymentRequestResponse paymentResponse)
{
if (reader == null)
throw new ArgumentNullException("reader");
if (paymentResponse == null)
throw new ArgumentNullException("paymentResponse");
if (reader.IsEmptyElement)
{
SerializationHelper.SkipNode(reader);
return;
}
string rootElement = reader.Name;
reader.ReadStartElement();
reader.MoveToContent();
while (!reader.EOF)
{
if (SerializationHelper.IsEndElement(reader, rootElement))
{
SerializationHelper.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case PaymentRequestResponseSerializer.Date:
paymentResponse.RegistrationDate = reader.ReadElementContentAsDateTime();
break;
case PaymentRequestResponseSerializer.Code:
paymentResponse.Code = reader.ReadElementContentAsString();
break;
default:
SerializationHelper.SkipElement(reader);
break;
}
}
else
{
SerializationHelper.SkipNode(reader);
}
}
}
示例9: Read
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="paymentResponse"></param>
internal static void Read(XmlReader reader, PaymentRequestResponse paymentResponse)
{
if (reader.IsEmptyElement)
{
XMLParserUtils.SkipNode(reader);
return;
}
string rootElement = reader.Name;
reader.ReadStartElement();
reader.MoveToContent();
while (!reader.EOF)
{
if (XMLParserUtils.IsEndElement(reader, rootElement))
{
XMLParserUtils.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case PaymentSerializer.Date:
paymentResponse.RegistrationDate = reader.ReadElementContentAsDateTime();
break;
case PaymentSerializer.Code:
paymentResponse.Code = reader.ReadElementContentAsString();
break;
case PaymentSerializer.TransactionCode:
paymentResponse.TransactionCode = reader.ReadElementContentAsString();
break;
default:
XMLParserUtils.SkipElement(reader);
break;
}
}
else
{
XMLParserUtils.SkipNode(reader);
}
}
}
示例10: Read
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="permission">PagSeguro AuthorizationPermissions</param>
internal static void Read(XmlReader reader, AuthorizationPermissions permission)
{
if (reader.IsEmptyElement)
{
XMLParserUtils.SkipNode(reader);
return;
}
reader.ReadStartElement(SerializerHelper.Permission);
reader.MoveToContent();
while (!reader.EOF)
{
if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Permission))
{
XMLParserUtils.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case SerializerHelper.Code:
permission.Code = reader.ReadElementContentAsString();
break;
case SerializerHelper.Status:
permission.Status = reader.ReadElementContentAsString();
break;
case SerializerHelper.LastUpdate:
permission.LastUpdate = reader.ReadElementContentAsDateTime();
break;
default:
XMLParserUtils.SkipElement(reader);
break;
}
}
else
{
XMLParserUtils.SkipNode(reader);
}
}
}
示例11: Read
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="result">PagSeguro AuthorizationSearchResult</param>
internal static void Read(XmlReader reader, AuthorizationSearchResult result)
{
if (reader.IsEmptyElement)
{
XMLParserUtils.SkipNode(reader);
return;
}
reader.ReadStartElement(SerializerHelper.AuthorizationSearchResult);
reader.MoveToContent();
while (!reader.EOF)
{
if (XMLParserUtils.IsEndElement(reader, SerializerHelper.AuthorizationSearchResult))
{
XMLParserUtils.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case SerializerHelper.Date:
result.Date = reader.ReadElementContentAsDateTime();
break;
case SerializerHelper.Authorizations:
AuthorizationSummaryListSerializer.Read(reader, result.Authorizations);
break;
default:
XMLParserUtils.SkipElement(reader);
break;
}
}
else
{
XMLParserUtils.SkipNode(reader);
}
}
}
示例12: Read
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="authorization">PagSeguro AuthorizationResponse</param>
internal static void Read(XmlReader reader, AuthorizationResponse authorization)
{
if (reader.IsEmptyElement)
{
XMLParserUtils.SkipNode(reader);
return;
}
reader.ReadStartElement();
reader.MoveToContent();
while (!reader.EOF)
{
if (XMLParserUtils.IsEndElement(reader, SerializerHelper.PreApproval))
{
XMLParserUtils.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case SerializerHelper.Code:
authorization.Code = reader.ReadElementContentAsString();
break;
case SerializerHelper.Date:
authorization.Date = reader.ReadElementContentAsDateTime();
break;
}
}
else
{
XMLParserUtils.SkipNode(reader);
}
}
}
示例13: LoadFromNode
private PlistObjectBase LoadFromNode(XmlReader reader)
{
//Debug.Assert(reader.NodeType == XmlNodeType.Element);
bool isEmpty = reader.IsEmptyElement;
switch (reader.LocalName)
{
case "dict":
var dict = new PlistDictionary(true);
if (!isEmpty)
{
if (reader.ReadToDescendant("key"))
dict = LoadDictionaryContents(reader, dict);
reader.ReadEndElement();
}
return dict;
case "array":
if (isEmpty)
return new PlistArray();
//advance to first node
reader.ReadStartElement();
while (reader.Read() && reader.NodeType != XmlNodeType.Element) ;
// HACK: plist data in iPods is not even valid in some cases! Way to go Apple!
// This hack checks to see if they really meant for this array to be a dict.
if (reader.LocalName == "key")
{
var ret = LoadDictionaryContents(reader, new PlistDictionary(true));
reader.ReadEndElement();
return ret;
}
var arr = new PlistArray();
do
{
if (reader.NodeType == XmlNodeType.Element)
{
var val = LoadFromNode(reader);
if (val != null)
arr.Add(val);
}
} while (reader.Read() && reader.NodeType != XmlNodeType.EndElement);
reader.ReadEndElement();
return arr;
case "key":
return new PlistString(reader.ReadElementContentAsString());
case "string":
return new PlistString(reader.ReadElementContentAsString());
case "integer":
return new PlistInteger(reader.ReadElementContentAsInt());
case "real":
return new PlistReal(reader.ReadElementContentAsDouble());
case "false":
reader.ReadStartElement();
if (!isEmpty)
reader.ReadEndElement();
return new PlistBoolean(false);
case "true":
reader.ReadStartElement();
if (!isEmpty)
reader.ReadEndElement();
return new PlistBoolean(true);
case "data":
return new PlistData(reader.ReadElementContentAsString());
case "date":
return new PlistDate(reader.ReadElementContentAsDateTime());
default:
throw new XmlException(String.Format("Plist Node `{0}' is not supported", reader.LocalName));
}
}
示例14: DeserializePrimitive
object DeserializePrimitive (Type type, XmlReader reader, QName qname)
{
// It is the only exceptional type that does not serialize to string but serializes into complex element.
if (type == typeof (DateTimeOffset)) {
if (reader.IsEmptyElement) {
reader.Read ();
return default (DateTimeOffset);
}
reader.ReadStartElement ();
reader.MoveToContent ();
var date = reader.ReadElementContentAsDateTime ("DateTime", KnownTypeCollection.DefaultClrNamespaceSystem);
var off = TimeSpan.FromMinutes (reader.ReadElementContentAsInt ("OffsetMinutes", KnownTypeCollection.DefaultClrNamespaceSystem));
reader.MoveToContent ();
reader.ReadEndElement ();
return new DateTimeOffset (DateTime.SpecifyKind (date.ToUniversalTime () + off, DateTimeKind.Unspecified), off);
}
string value;
if (reader.IsEmptyElement) {
reader.Read (); // advance
if (type.IsValueType)
return Activator.CreateInstance (type);
else
// FIXME: Workaround for creating empty objects of the correct type.
value = String.Empty;
}
else
value = reader.ReadElementContentAsString ();
return KnownTypeCollection.PredefinedTypeStringToObject (value, qname.Name, reader);
}
示例15: FromXml
internal static Workspace FromXml(Repository repository, XmlReader reader)
{
string elementName = reader.Name;
string computer = reader.GetAttribute("computer");
string name = reader.GetAttribute("name");
string owner = reader.GetAttribute("owner");
string comment = "";
DateTime lastAccessDate = DateTime.Now;
List<WorkingFolder> folders = new List<WorkingFolder>();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName)
break;
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "WorkingFolder":
folders.Add(WorkingFolder.FromXml(repository, reader));
break;
case "Comment":
comment = reader.ReadString();
break;
case "LastAccessDate":
lastAccessDate = reader.ReadElementContentAsDateTime();
break;
}
}
}
Workspace w = new Workspace(repository.VersionControlServer, name, owner, comment, folders.ToArray(), computer);
w.lastAccessDate = lastAccessDate;
return w;
}