Пример #1
0
 /// <remarks>
 /// I'm not a huge fan of this manual cloning.
 /// However, I'm choosing this over taking a dependency on a mapper
 /// or performing a deep clone that includes the Recipients collection unnecessarily.
 /// </remarks>
 private static SelectRecipientData CloneWithoutRecipients(SelectRecipientData contact)
 {
     return(new SelectRecipientData()
     {
         DatabaseId = contact.DatabaseId,
         Columns = contact.Columns,
     });
 }
Пример #2
0
        public virtual string Encode(SelectRecipientData message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            var xml             = new XElement(XName.Get("Envelope"));
            var bodyXml         = new XElement(XName.Get("Body"));
            var addReceipentXml = new XElement(XName.Get("SelectRecipientData"));

            addReceipentXml.SetElementValue(XName.Get("LIST_ID"), message.DatabaseId);
            addReceipentXml.SetElementValue(XName.Get("EMAIL"), message.Email);
            // Add COLUMNS
            if (message.Columns.Count > 0)
            {
                foreach (var column in message.Columns)
                {
                    var columnXml = new XElement(XName.Get("COLUMN"));
                    var name      = new XElement(XName.Get("NAME"))
                    {
                        Value = column.Key
                    };
                    var value = new XElement(XName.Get("VALUE"))
                    {
                        Value = column.Value
                    };

                    columnXml.Add(name);
                    columnXml.Add(value);

                    addReceipentXml.Add(columnXml);
                }
            }
            bodyXml.Add(addReceipentXml);
            xml.Add(bodyXml);

            return(xml.ToString());
        }