private void BodyPart() { if (IsBodyPart()) { Expect(3); Console.WriteLine("Entering terminal part ..."); var part = new BodyPart(); Part parent; var success = TrySaveToParent(part, out parent); if (success) { part.Parent = parent; } PushPart(part); Field(); CurrentBodyPart.BodyType = t.val.TrimQuotes(); Field(); CurrentBodyPart.SubType = t.val.TrimQuotes(); CurrentListType = ParamListType.BodyPart; ParamList(); Field(); CurrentBodyPart.BodyId = t.val.TrimQuotes(); CurrentListType = ParamListType.Other; Field(); CurrentBodyPart.BodyDescription = t.val.TrimQuotes(); Field(); CurrentBodyPart.BodyEncoding = t.val.TrimQuotes(); Expect(2); CurrentBodyPart.BodySize = t.val.TrimQuotes(); while (la.kind == 2) { Get(); } CurrentBodyPart.TextLines = t.val.TrimQuotes(); BodyPartAppendix(); Expect(4); Console.WriteLine("Leaving terminal part."); _stack.Pop(); } else if (la.kind == 3) { MultiPart(); } else { SynErr(7); } }
private static void AddNestedMessage(MessageInfo message, BodyPart current, string token, int sn, string original) { var nested = new MessageInfo { SequenceNumber = sn, Token = token, OriginalString = original }; nested.Token = token; nested.SequenceNumber = sn; var envelope = original.Substring(current.EnvelopeBounds[0], current.EnvelopeBounds[1]); var parser = new EnvelopeParser(); nested.Envelope = (Envelope) parser.Parse(envelope, null); ((List<MessageInfo>) message.NestedMessages).Add(nested); var i = 0; foreach (var child in current.Children) { i += 1; var childToken = (token + "." + i).TrimStart('.'); ProcessChild(nested, child, childToken, sn, original); } }
private static void AddView(MessageInfo message, BodyPart child, string token, int sn) { var mediaType = (child.BodyType + "/" + child.SubType).ToLower(); var view = new ViewInfo { Description = child.BodyDescription.ToUpper() == "NIL" ? string.Empty : child.BodyDescription, Id = child.BodyId.ToUpper() == "NIL" ? string.Empty : child.BodyId, ContentTransferEncoding = string.IsNullOrEmpty(child.BodyEncoding) ? string.Empty : child.BodyEncoding.ToLower(), MediaType = mediaType, Token = token, SequenceNumber = sn }; int size; var success = int.TryParse(child.BodySize, out size); if (success) { view.SizeEncoded = Size.FromBytes(size); } else { Debug.WriteLine(string.Format("Unable to parse body size. Value is not numeric: '{0}'", child.BodySize)); } int lines; success = int.TryParse(child.TextLines, out lines); if (success) { view.TextLinesEncoded = lines; } var paramDictionary = (ParameterDictionary)view.Parameters; paramDictionary.AddRange(child.Parameters); ((IList<ViewInfo>) message.Views).Add(view); }
private static void AddAttachment(MessageInfo message, BodyPart child, string token, int sn) { var attachment = new AttachmentInfo { ContentTransferEncoding = string.IsNullOrEmpty(child.BodyEncoding) ? string.Empty : child.BodyEncoding.ToLower(), MediaType = (child.BodyType + "/" + child.SubType).ToLower(), Token = token, SequenceNumber = sn }; int size; var success = int.TryParse(child.BodySize, out size); if (success) { attachment.SizeEncoded = Size.FromBytes(size); } else { Debug.WriteLine(string.Format("Unable to parse body size. Value is not numeric: '{0}'", child.BodySize)); } if (child.Parameters.ContainsKey("name")) { attachment.Name = child.Parameters["name"]; } ((ParameterDictionary) attachment.Parameters).AddRange(child.Parameters); ((IList<AttachmentInfo>) message.Attachments).Add(attachment); }