Exemple #1
0
        private static string GetSerializedPerson()
        {
            var xml = string.Empty;

            Person person = new Person() { Name = "testPerson", Age = 24, ID = 12345, Active = true };

            XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(person.GetType());
            using (MemoryStream memStream = new MemoryStream())
            {
                XmlTextWriter xmlWriter = new XmlTextWriter(memStream, Encoding.UTF8);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.Indentation = 1;
                xmlWriter.IndentChar = Convert.ToChar(9);
                ser.Serialize(xmlWriter, person);
                xmlWriter.Close();
                memStream.Close();
                xml = Encoding.UTF8.GetString(memStream.GetBuffer());
                xml = xml.Substring(xml.IndexOf(Convert.ToChar(60)));
                xml = xml.Substring(0, (xml.LastIndexOf(Convert.ToChar(62)) + 1));
            }
            return xml;
        }
 partial void UpdatePerson(Person instance);
 partial void DeletePerson(Person instance);
 partial void InsertPerson(Person instance);