Exemplo n.º 1
0
        /// <summary>
        /// Creates an envelope item from file.
        /// </summary>
        public static EnvelopeItem FromFile(string filePath)
        {
            var file    = File.OpenRead(filePath);
            var payload = new StreamSerializable(file);

            var header = new Dictionary <string, object>
            {
                [TypeKey]     = "attachment",
                [FileNameKey] = Path.GetFileName(filePath),
                [LengthKey]   = file.Length
            };

            return(new EnvelopeItem(header, payload));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an envelope item from text.
        /// </summary>
        public static EnvelopeItem FromString(string text)
        {
            using var buffer = new MemoryStream(
                      Encoding.UTF8.GetBytes(text)
                      );

            var payload = new StreamSerializable(buffer);

            var header = new Dictionary <string, object>
            {
                [TypeKey]   = "attachment",
                [LengthKey] = buffer.Length
            };

            return(new EnvelopeItem(header, payload));
        }