using System.Collections;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Xml.Linq;

namespace PlatezhkaDemoApi.Utils {
    public static class XmlDictionarySerializer {
        public static string Serialize(this IDictionary dictionary) {
            var xElem = new XElement("fields");
            xElem.Add();

            int i = 1;
            foreach (var key in dictionary.Keys) {
                var field = new XElement("field" + i, new XAttribute("name", key), dictionary[key]);
                xElem.Add(field);
                i++;
            }

            return xElem.ToString();
        }
    }
}