Ejemplo n.º 1
0
        private static void AddToListIfNotEmpty(string attachmentContent, string attachmentFileName, List <AssaAttachment> attachments, string category)
        {
            var content = attachmentContent.Trim();

            if (!string.IsNullOrWhiteSpace(attachmentFileName) && !string.IsNullOrEmpty(content))
            {
                var bytes = UUEncoding.UUDecode(content);
                attachments.Add(new AssaAttachment {
                    FileName = attachmentFileName, Bytes = bytes, Category = category, Content = content
                });
            }
        }
Ejemplo n.º 2
0
        private void SaveFontNames(string attachmentFileName, string attachmentContent, string category)
        {
            var content = attachmentContent.Trim();

            if (string.IsNullOrEmpty(attachmentFileName) || content.Length == 0 || !attachmentFileName.EndsWith(".ttf", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            var bytes = UUEncoding.UUDecode(content);

            foreach (var fontName in GetFontNames(bytes))
            {
                _fontAttachments.Add(new AssaAttachmentFont {
                    FileName = attachmentFileName, FontName = fontName, Bytes = bytes, Category = category, Content = content
                });
            }
        }
Ejemplo n.º 3
0
        public void ForwardAndBackAgain()
        {
            var byteArray = new byte[byte.MaxValue];

            for (int i = byte.MinValue; i < byte.MaxValue; i++)
            {
                byteArray[i] = (byte)i;
            }

            var text     = UUEncoding.UUEncode(byteArray);
            var newBytes = UUEncoding.UUDecode(text);

            Assert.AreEqual(byteArray.Length, newBytes.Length);
            for (int i = byte.MinValue; i < byte.MaxValue; i++)
            {
                Assert.AreEqual(byteArray[i], newBytes[i]);
            }
        }
Ejemplo n.º 4
0
        private void AddToListView(string attachmentFileName, string attachmentContent, string category)
        {
            var content = attachmentContent.Trim();

            if (string.IsNullOrEmpty(attachmentFileName) || content.Length == 0)
            {
                return;
            }

            var item  = new ListViewItem(attachmentFileName);
            var bytes = UUEncoding.UUDecode(content);

            _attachments.Add(new AssaAttachment {
                FileName = attachmentFileName, Bytes = bytes, Category = category, Content = content
            });
            item.SubItems.Add(GetType(attachmentFileName));
            item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(bytes.Length));
            listViewAttachments.Items.Add(item);
        }