public void Write(SimpleXmlWriter writer)
            {
                var properties = Type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);

                writer.WriteStartElement(Type.Name);

                foreach (var property in properties)
                {
                    string stringValue = "";
                    object value       = property.GetValue(Object, null);

                    Type valueType = value?.GetType();

                    if (valueType != null)
                    {
                    }

                    if (value != null)
                    {
                        if (valueType.IsPrimitive || valueType == typeof(string))
                        {
                            stringValue = Convert.ToString(value);
                            writer.WriteElementString(property.Name, stringValue);
                        }
                    }
                }

                writer.WriteFullEndElement();
            }
        public string Serialize(SimpleXmlWriter xmlWriter, object o)
        {
            var serializer = new ErrorTolerantXmlWriter(o);

            serializer.Write(xmlWriter);
            return(xmlWriter.ToString());
        }