Microsoft.Protocols.TestSuites.MS_WSSREST.TestSuiteBase.GenerateContent C# (CSharp) Method

GenerateContent() protected method

Generate the http request body.
protected GenerateContent ( string>.Dictionary properties ) : string
properties string>.Dictionary The dictionary that contains field name and field value.
return string
        protected string GenerateContent(Dictionary<string, string> properties)
        {
            if (properties != null && properties.Count > 0)
            {
                XmlDocument doc = new XmlDocument();
                XmlElement rootElement = doc.CreateElement("entry");
                rootElement.SetAttribute("xmlns:d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
                rootElement.SetAttribute("xmlns:m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
                rootElement.SetAttribute("xmlns", "http://www.w3.org/2005/Atom");

                XmlElement content = doc.CreateElement("content");
                content.SetAttribute("type", "application/xml");

                XmlElement property = doc.CreateElement("m", "properties", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
                foreach (KeyValuePair<string, string> item in properties)
                {
                    XmlElement propertyItem = doc.CreateElement("d", item.Key, "http://schemas.microsoft.com/ado/2007/08/dataservices");
                    propertyItem.InnerText = item.Value;
                    property.AppendChild(propertyItem);
                }

                doc.AppendChild(rootElement);
                rootElement.AppendChild(content);
                content.AppendChild(property);

                return doc.OuterXml;
            }
            else
            {
                return string.Empty;
            }
        }