Exemplo n.º 1
0
        public override string SerializeToString(object obj)
        {
            IAttachment a = obj as IAttachment;

            if (a != null)
            {
                if (a.Uri != null)
                {
                    if (a.Parameters.ContainsKey("VALUE"))
                    {
                        // Ensure no VALUE type is provided
                        a.Parameters.Remove("VALUE");
                    }

                    return(Encode(a, a.Uri.OriginalString));
                }
                else if (a.Data != null)
                {
                    // Ensure the VALUE type is set to BINARY
                    a.SetValueType("BINARY");

                    // BASE64 encoding for BINARY inline attachments.
                    a.Parameters.Set("ENCODING", "BASE64");

                    return(Encode(a, a.Data));
                }
            }
            return(null);
        }