Braintree.RequestBuilder.BuildXMLElement C# (CSharp) Method

BuildXMLElement() static private method

static private BuildXMLElement ( string name, object value ) : string
name string
value object
return string
        internal static string BuildXMLElement(string name, object value)
        {
            if (value == null)
            {
                return "";
            }
            if (value is Request)
            {
                return ((Request) value).ToXml(name);
            }
            if (value is DateTime)
            {
                return FormatAsXml(name, (DateTime) value);
            }
            if (value is bool)
            {
                return FormatAsXml(name, value.ToString().ToLower());
            }
            if (value is Array)
            {
                var xml = "";
                foreach (var item in (Array)value)
                {
                    xml += BuildXMLElement("item", item);
                }
                return FormatAsArrayXML(name, xml);
            }
            if (value is Dictionary<string, string>)
            {
                return FormatAsXml(name, (Dictionary<string, string>) value);
            }
            if (value is decimal)
            {
                return FormatAsXml(name, ((decimal) value).ToString("F2", System.Globalization.CultureInfo.InvariantCulture));
            }

            return FormatAsXml(name, value.ToString());
        }

Usage Example

Esempio n. 1
0
 public override string ToXml()
 {
     if (Comments != null)
     {
         return(RequestBuilder.BuildXMLElement("comments", Comments));
     }
     if (DocumentUploadId != null)
     {
         return(RequestBuilder.BuildXMLElement("document-upload-id", DocumentUploadId));
     }
     return("");
 }
All Usage Examples Of Braintree.RequestBuilder::BuildXMLElement