本文整理汇总了C#中System.Xml.XmlDictionaryReader.ReadContentAsDateTime方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.ReadContentAsDateTime方法的具体用法?C# XmlDictionaryReader.ReadContentAsDateTime怎么用?C# XmlDictionaryReader.ReadContentAsDateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.ReadContentAsDateTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadTimestamp
internal override SecurityTimestamp ReadTimestamp(XmlDictionaryReader reader, string digestAlgorithm, SignatureResourcePool resourcePool)
{
DateTime maxUtcDateTime;
byte[] buffer;
bool flag = (digestAlgorithm != null) && reader.CanCanonicalize;
HashStream stream = null;
reader.MoveToStartElement(System.ServiceModel.XD.UtilityDictionary.Timestamp, System.ServiceModel.XD.UtilityDictionary.Namespace);
if (flag)
{
stream = resourcePool.TakeHashStream(digestAlgorithm);
reader.StartCanonicalization(stream, false, null);
}
string attribute = reader.GetAttribute(System.ServiceModel.XD.UtilityDictionary.IdAttribute, System.ServiceModel.XD.UtilityDictionary.Namespace);
reader.ReadStartElement();
reader.ReadStartElement(System.ServiceModel.XD.UtilityDictionary.CreatedElement, System.ServiceModel.XD.UtilityDictionary.Namespace);
DateTime creationTimeUtc = reader.ReadContentAsDateTime().ToUniversalTime();
reader.ReadEndElement();
if (reader.IsStartElement(System.ServiceModel.XD.UtilityDictionary.ExpiresElement, System.ServiceModel.XD.UtilityDictionary.Namespace))
{
reader.ReadStartElement();
maxUtcDateTime = reader.ReadContentAsDateTime().ToUniversalTime();
reader.ReadEndElement();
}
else
{
maxUtcDateTime = System.ServiceModel.Security.SecurityUtils.MaxUtcDateTime;
}
reader.ReadEndElement();
if (flag)
{
reader.EndCanonicalization();
buffer = stream.FlushHashAndGetValue();
}
else
{
buffer = null;
}
return new SecurityTimestamp(creationTimeUtc, maxUtcDateTime, attribute, digestAlgorithm, buffer);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:WSUtilitySpecificationVersion.cs
示例2: ReadTimestamp
internal override SecurityTimestamp ReadTimestamp(XmlDictionaryReader reader, string digestAlgorithm, SignatureResourcePool resourcePool)
{
bool canonicalize = digestAlgorithm != null && reader.CanCanonicalize;
HashStream hashStream = null;
reader.MoveToStartElement(XD.UtilityDictionary.Timestamp, XD.UtilityDictionary.Namespace);
if (canonicalize)
{
hashStream = resourcePool.TakeHashStream(digestAlgorithm);
reader.StartCanonicalization(hashStream, false, null);
}
string id = reader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace);
reader.ReadStartElement();
reader.ReadStartElement(XD.UtilityDictionary.CreatedElement, XD.UtilityDictionary.Namespace);
DateTime creationTimeUtc = reader.ReadContentAsDateTime().ToUniversalTime();
reader.ReadEndElement();
DateTime expiryTimeUtc;
if (reader.IsStartElement(XD.UtilityDictionary.ExpiresElement, XD.UtilityDictionary.Namespace))
{
reader.ReadStartElement();
expiryTimeUtc = reader.ReadContentAsDateTime().ToUniversalTime();
reader.ReadEndElement();
}
else
{
expiryTimeUtc = SecurityUtils.MaxUtcDateTime;
}
reader.ReadEndElement();
byte[] digest;
if (canonicalize)
{
reader.EndCanonicalization();
digest = hashStream.FlushHashAndGetValue();
}
else
{
digest = null;
}
return new SecurityTimestamp(creationTimeUtc, expiryTimeUtc, id, digestAlgorithm, digest);
}
示例3: WriteTextNode
protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
{
Type valueType = reader.ValueType;
if (valueType == typeof(string))
{
XmlDictionaryString str;
if (reader.TryGetValueAsDictionaryString(out str))
{
this.WriteString(str);
}
else if (reader.CanReadValueChunk)
{
int num;
if (this.chars == null)
{
this.chars = new char[0x100];
}
while ((num = reader.ReadValueChunk(this.chars, 0, this.chars.Length)) > 0)
{
this.WriteChars(this.chars, 0, num);
}
}
else
{
this.WriteString(reader.Value);
}
if (!attribute)
{
reader.Read();
}
}
else if (valueType == typeof(byte[]))
{
if (reader.CanReadBinaryContent)
{
int num2;
if (this.bytes == null)
{
this.bytes = new byte[0x180];
}
while ((num2 = reader.ReadValueAsBase64(this.bytes, 0, this.bytes.Length)) > 0)
{
this.WriteBase64(this.bytes, 0, num2);
}
}
else
{
this.WriteString(reader.Value);
}
if (!attribute)
{
reader.Read();
}
}
else if (valueType == typeof(int))
{
this.WriteValue(reader.ReadContentAsInt());
}
else if (valueType == typeof(long))
{
this.WriteValue(reader.ReadContentAsLong());
}
else if (valueType == typeof(bool))
{
this.WriteValue(reader.ReadContentAsBoolean());
}
else if (valueType == typeof(double))
{
this.WriteValue(reader.ReadContentAsDouble());
}
else if (valueType == typeof(DateTime))
{
this.WriteValue(reader.ReadContentAsDateTime());
}
else if (valueType == typeof(float))
{
this.WriteValue(reader.ReadContentAsFloat());
}
else if (valueType == typeof(decimal))
{
this.WriteValue(reader.ReadContentAsDecimal());
}
else if (valueType == typeof(UniqueId))
{
this.WriteValue(reader.ReadContentAsUniqueId());
}
else if (valueType == typeof(Guid))
{
this.WriteValue(reader.ReadContentAsGuid());
}
else if (valueType == typeof(TimeSpan))
{
this.WriteValue(reader.ReadContentAsTimeSpan());
}
else
{
this.WriteValue(reader.ReadContentAsObject());
}
}
示例4: WriteTextNode
protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
{
Type type = reader.ValueType;
if (type == typeof(string))
{
XmlDictionaryString value;
if (reader.TryGetValueAsDictionaryString(out value))
{
WriteString(value);
}
else
{
if (reader.CanReadValueChunk)
{
if (chars == null)
{
chars = new char[256];
}
int count;
while ((count = reader.ReadValueChunk(chars, 0, chars.Length)) > 0)
{
this.WriteChars(chars, 0, count);
}
}
else
{
WriteString(reader.Value);
}
}
if (!attribute)
{
reader.Read();
}
}
else if (type == typeof(byte[]))
{
if (reader.CanReadBinaryContent)
{
// Its best to read in buffers that are a multiple of 3 so we don't break base64 boundaries when converting text
if (bytes == null)
{
bytes = new byte[384];
}
int count;
while ((count = reader.ReadValueAsBase64(bytes, 0, bytes.Length)) > 0)
{
this.WriteBase64(bytes, 0, count);
}
}
else
{
WriteString(reader.Value);
}
if (!attribute)
{
reader.Read();
}
}
else if (type == typeof(int))
WriteValue(reader.ReadContentAsInt());
else if (type == typeof(long))
WriteValue(reader.ReadContentAsLong());
else if (type == typeof(bool))
WriteValue(reader.ReadContentAsBoolean());
else if (type == typeof(double))
WriteValue(reader.ReadContentAsDouble());
else if (type == typeof(DateTime))
WriteValue(reader.ReadContentAsDateTime());
else if (type == typeof(float))
WriteValue(reader.ReadContentAsFloat());
else if (type == typeof(decimal))
WriteValue(reader.ReadContentAsDecimal());
else if (type == typeof(UniqueId))
WriteValue(reader.ReadContentAsUniqueId());
else if (type == typeof(Guid))
WriteValue(reader.ReadContentAsGuid());
else if (type == typeof(TimeSpan))
WriteValue(reader.ReadContentAsTimeSpan());
else
WriteValue(reader.ReadContentAsObject());
}
示例5: ReadLinkItem
public static LinkItem ReadLinkItem(XmlDictionaryReader reader)
{
LinkItem linkItem = new LinkItem();
if (reader.IsStartElement("Id", ns))
{
reader.MoveToContent();
linkItem.Id = int.Parse(reader.ReadString());
reader.MoveToContent();
reader.ReadEndElement();
}
else
throw new XmlException("ExpectedElementMissing: Id element was expected.");
if (reader.IsStartElement("Title", ns))
{
reader.MoveToContent();
linkItem.Title = reader.ReadString();
reader.MoveToContent();
reader.ReadEndElement();
}
else
throw new XmlException("ExpectedElementMissing: Title element was expected.");
if (reader.IsStartElement("Description", ns ))
{
reader.MoveToContent();
linkItem.Description = reader.ReadString();
reader.MoveToContent();
reader.ReadEndElement();
}
else
throw new XmlException("ExpectedElementMissing: Description element was expected.");
if (reader.IsStartElement("DateStart", ns))
{
reader.MoveToContent();
reader.Read();
linkItem.DateStart = reader.ReadContentAsDateTime();
reader.MoveToContent();
reader.ReadEndElement();
}
else
throw new XmlException("ExpectedElementMissing: DateStart element was expected.");
if (reader.IsStartElement("DateEnd", ns))
{
reader.MoveToContent();
reader.Read();
linkItem.DateEnd = reader.ReadContentAsDateTime();
reader.MoveToContent();
reader.ReadEndElement();
}
// optional
if (reader.IsStartElement("Url", ns))
{
reader.MoveToContent();
linkItem.Url = reader.ReadString();
reader.MoveToContent();
reader.ReadEndElement();
}
else
throw new XmlException("ExpectedElementMissing: Url element was expected.");
return linkItem;
}