本文整理汇总了C#中System.Entity.Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.Deserialize方法的具体用法?C# Entity.Deserialize怎么用?C# Entity.Deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Entity
的用法示例。
在下文中一共展示了Entity.Deserialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadResponse
internal override void ReadResponse(Pop3ResponseReader reader)
{
TakeSnapshot(reader);
if (IsNegative) {
return;
}
using (var writer = new StringWriter()) {
while (true) {
reader.ReadNextLine();
if (reader.IsCompleted) {
break;
}
writer.WriteLine(reader.CurrentLine.StartsWith("..")
? reader.CurrentLine.Substring(1)
: reader.CurrentLine);
}
var text = writer.ToString();
var index = text.IndexOf(Strings.CrLf + Strings.CrLf);
var entity = new Entity();
entity.Deserialize(text.Substring(0, index));
_headerFields.AddRange(entity.Headers);
Lines = text.Substring(index).Trim();
}
}
示例2: FromMime
public static Message FromMime(string text)
{
var entity = new Entity();
entity.Deserialize(text);
return entity.ToMessage();
}
示例3: FetchMessageByUid
/// <summary>
/// Fetches a single message from the selected mailbox identified by its unique identifier.
/// </summary>
/// <param name="uid">The uid of the requested message.</param>
/// <returns>The requested message.</returns>
public Message FetchMessageByUid(int uid)
{
var query = Messages
.Where(x => x.Uid == uid)
.Select(x => new MessageContainer {
Uid = x.Uid,
SequenceNumber = x.SequenceNumber,
Text = (string) x.Parts(string.Empty)
});
var container = query.ToList().FirstOrDefault();
if (container != null) {
var entity = new Entity();
entity.Deserialize(container.Text);
var message = entity.ToMessage();
message.Uid = container.Uid;
message.SequenceNumber = container.SequenceNumber;
return message;
}
return null;
}
示例4: FetchNestedMessage
/// <summary>
/// Fetches a single nested message from the requested message.
/// </summary>
/// <param name="info">The associated info object, this token can be obtained from the messages body structure.</param>
/// <returns>The requested nested message.</returns>
public Message FetchNestedMessage(MessageInfo info)
{
var text = FetchEntityText(info);
if (string.IsNullOrEmpty(text)) {
return null;
}
var entity = new Entity();
entity.Deserialize(text);
return entity.ToMessage();
}
示例5: ParseEntity
private static View ParseEntity(Message message, Entity current, Entity last, View related = null)
{
if (current.IsMessage()) {
var e = new Entity();
e.Deserialize(current.Text);
var nested = e.ToMessage();
message.NestedMessages.Add(nested);
return null;
}
if (related != null) {
var attachment = current.ToRelated();
related.RelatedAttachments.Add(attachment);
return related;
}
if (current.IsAttachment()) {
var attachment = current.ToAttachment();
message.Attachments.Add(attachment);
return null;
}
if (current.IsView() || !current.HasContentType) {
var view = current.ToView();
message.Views.Add(view);
if (last != null && last.IsMultipartRelated) {
return view;
}
return null;
}
foreach (var child in current.Children) {
// we need to pass the related view to the next sibling
related = ParseEntity(message, child, current, related);
}
return null;
}